Hello, I'm Corinne.
The above all() function is a function that returns True if it is of an optional type, such as a list or dictionary.
I'm asking you because I don't know what the conditions for returning False are.
TypeError: 'int' object is not iterable
If you insert a non-iterable type, you will vomit the above typeerrr.
What is the condition of the notator?
python
Condition to return false
0 or " (empty string)
a = [1,2,0,4,5]
print(all(a)) # False
b = ""
print(all(b)) # False
For example, if you have a list of students' gender,
Starlight Class Student Sex = ["Other", "Other", "Other", "Other", "Other", "Other", "Other"]
Are you a starlight class student? = [Gender == "Men" for Gender in Starlight class]
If all:
print ("All men!"
else:
print ("There are girls, too!")
You can write it like this.
© 2024 OneMinuteCode. All rights reserved.