Guest User

Untitled

a guest
Jan 17th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. myDict = { 0 : ['a','b','c'],
  2. 1 : ['d','e','f']}
  3.  
  4. any('a' in lst for lst in myDict.values())
  5.  
  6. for x in y:
  7. if condition:
  8. return True
  9. return False
  10. # return any(condition for x in y)
  11.  
  12. myDict = { 0 : ['a','b','c'],
  13. 1 : ['d','e','f']}
  14.  
  15. rset = {x for v in myDict.values() for x in v}
  16.  
  17. print(rset)
  18.  
  19. {'b', 'e', 'c', 'd', 'a', 'f'}
  20.  
  21. 'a' in rset
  22.  
  23. from itertools import chain
  24.  
  25. if 'a' in chain.from_iterable(myDict.values()):
  26. # do something
  27. pass
  28.  
  29. if 'a' in myDict[0]:
  30. # do something
  31. pass
  32.  
  33. # will not error, but False in case key does not exists
  34. if 'a' in myDict.get(0, ()):
  35. # do something
  36. pass
Add Comment
Please, Sign In to add comment