all(my_iterable)
my_iterable : iterable input| Elements of the iterable | any() Output | all() Output |
|---|---|---|
| All are True | True | True |
| All are False | False | False |
| One value is True ( Others False) | True | False |
| One value is False ( Others True) | True | False |
| Empty | False | True |
list=[]
print(all(list)) # True
List ( More on python list )
list = [1, 2, 3, 4, 55]
print(all(list)) # True
list = [0, False]
print(all(list)) # False
list = [False, True]
print(all(list)) # False
url = 'plus2net.com'
print(all(url)) # True
url = 'False'
print(all(url)) # True
We will use Dictionarymy_dict = {0: 'A', 1: 'B'}
print(all(my_dict)) # False
my_dict = {0: 'A', 0: 'B'}
print(all(my_dict)) # False
my_dict = {0: True, 0: False}
print(all(my_dict)) # False
my_dict = {1: True, 2: False}
print(all(my_dict)) # True
We will use tuplemy_tuple = (True, 1, 12)
print(all(my_tuple)) # True
my_tuple = (True, 0)
print(all(my_tuple)) # False
my_tuple = (0, 0)
print(all(my_tuple)) # False
my_tuple = (0, 1)
print(all(my_tuple)) # False
Using if else
a, b, c = 0, 0, 1
if all((a, b, c)):
print("Yes")
else:
print("No") # Output No
any()
Iterator
in and not in Membership operators
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.