[Tutor] all( ) built in function

Sibylle Koczian nulla.epistola at web.de
Wed Oct 14 14:42:01 EDT 2020


Am 14.10.2020 um 19:26 schrieb Manprit Singh:
> Dear Sir ,
> 
> I just want to check my understanding of using all( ), a  built in
> function, with examples  given below :
> 
> test_seq  = [ [2, 3], [3, 6], [ ], [4, 8] ]
> all(test_seq) will return False as test_seq contains an empty list which is
> considered  as false object when tested for truth value
> 
> t_lst = [3, 5, 6, 0, 7]
> all(t_lst) will also return False as t_lst contains a 0 which is
> considered  as a false object when tested for truth value.
> 
> test_s = [None, True, True, True]
> all(test_s) will also return False as test_s contains None which is
> considered  as a false object when tested for truth value.
> 
> t_s = [3, 5, 8, 9]
> all(t_s) will return True as every element of t_s is considered as a true
> object when tested for truth value.
> 

What did your interactive Python interpreter say?




More information about the Tutor mailing list