Guest User

Untitled

a guest
Mar 20th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. >>> mydict = {}
  2. >>> if (mydict.get('aaa') and mydict['aaa'] == 'ni'):
  3. ...: print("true")
  4. ...: else:
  5. ...: print("false")
  6. ...:
  7. false
  8. >>> if (all([mydict.get('aaa'), mydict['aaa'] == 'ni'])):
  9. ...: print("true")
  10. ...: else:
  11. ...: print("false")
  12. ...:
  13. KeyError Traceback (most recent call last)
  14. <ipython-input-5-adddd34f38ce> in <module>()
  15. 1 if (all([mydict.get('aaa'), mydict['aaa'] == 'ni'])):
  16. 2 print("true")
  17. 3 else:
  18. 4 print("false")
  19. 5
Add Comment
Please, Sign In to add comment