1The any() function takes an iterable (list, string, dictionary etc.) in Python.
2
3The any() function returns the boolean value:
4
5True if at least one element of an iterable is true
6False if all elements are false or if an iterable is empty
7
8Example:
9some_list = [1, 2, 3]
10print(any(some_list)) # True
11another_list = []
12print(any(another_list)) # False
1# True since 1,3 and 4 (at least one) is true
2l = [1, 3, 4, 0]
3print(any(l))
4
5# False since both are False
6l = [0, False]
7print(any(l))
8
9# True since 5 is true
10l = [0, False, 5]
11print(any(l))
1s = input()
2 print(any(i.isalnum() for i in s))
3 print(any(i.isalpha() for i in s))
4 print(any(i.isdigit() for i in s))
5 print(any(i.islower() for i in s))
6 print(any(i.isupper() for i in s))
1# True since 1,3 and 4 (at least one) is true
2l = [1, 3, 4, 0]
3print(any(l))
4
5# False since both are False
6l = [0, False]
7print(any(l))
8
9# True since 5 is true
10l = [0, False, 5]
11print(any(l))
12
13# False since iterable is empty
14l = []
15print(any(l))