Laur's blog
  • Home
  • About
  • Support my work
Sign in Subscribe

iterative

A collection of 1 post
Cascade get value from dictionary in Python
cascade

Cascade get value from dictionary in Python

Several times I've been faced with the problem: Get a value from a dictionary. If the key is not present, then get from another key. Normally, the implementation would go like this: if dict.has_key(key1): return dict[key1] elif dict.has_key(key2): return dict[key2]
May 31, 2016 1 min read
Page 1 of 1
Laur's blog © 2025
  • Sign up
Powered by Ghost