?
Which built-in function is used to check if all elements in an iterable are true?
Answer & Solution
Correct Answer:
Option
A
The correct answer is Option A: all().
The all() function in Python is used to check if all elements in an iterable are true.
It takes an iterable as an argument and returns True if all elements in the iterable are true, otherwise False.
For example:
The all() function in Python is used to check if all elements in an iterable are true.
It takes an iterable as an argument and returns True if all elements in the iterable are true, otherwise False.
For example:
my_list = [True, True, True]
result = all(my_list)
print(result) # Output: True
Join the Discussion
Login to post a comment or share your explanation.
Login