Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- myDict = { 0 : ['a','b','c'],
- 1 : ['d','e','f']}
- any('a' in lst for lst in myDict.values())
- for x in y:
- if condition:
- return True
- return False
- # return any(condition for x in y)
- myDict = { 0 : ['a','b','c'],
- 1 : ['d','e','f']}
- rset = {x for v in myDict.values() for x in v}
- print(rset)
- {'b', 'e', 'c', 'd', 'a', 'f'}
- 'a' in rset
- from itertools import chain
- if 'a' in chain.from_iterable(myDict.values()):
- # do something
- pass
- if 'a' in myDict[0]:
- # do something
- pass
- # will not error, but False in case key does not exists
- if 'a' in myDict.get(0, ()):
- # do something
- pass
Add Comment
Please, Sign In to add comment