How to check if any key of a dictionary are true in Python

1 Answer

0 votes
dict = {0: 'False'}
print(any(dict))

dict = {0: 'False', 1: 'True'}
print(any(dict))

dict = {False: 0, 0: 'False'}
print(any(dict))

dict = {'0': 'False'}
print(any(dict))

dict = {}
print(any(dict))





'''
run:

False
True
False
True
False

'''

 



answered Apr 25, 2021 by avibootz

Related questions

1 answer 133 views
1 answer 153 views
3 answers 333 views
4 answers 448 views
1 answer 173 views
1 answer 172 views
2 answers 191 views
...