Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> mydict = {}
- >>> if (mydict.get('aaa') and mydict['aaa'] == 'ni'):
- ...: print("true")
- ...: else:
- ...: print("false")
- ...:
- false
- >>> if (all([mydict.get('aaa'), mydict['aaa'] == 'ni'])):
- ...: print("true")
- ...: else:
- ...: print("false")
- ...:
- KeyError Traceback (most recent call last)
- <ipython-input-5-adddd34f38ce> in <module>()
- 1 if (all([mydict.get('aaa'), mydict['aaa'] == 'ni'])):
- 2 print("true")
- 3 else:
- 4 print("false")
- 5
Add Comment
Please, Sign In to add comment