[Tutor] all( ) built in function

Mark Lawrence breamoreboy at gmail.com
Wed Oct 14 13:44:29 EDT 2020


On 14/10/2020 18:26, Manprit Singh wrote:
> 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.
> 
> Your precious comments needed
> Regards
> Manprit Singh
> 
> Kindly let me know
> 

Your examples seem to match the documentation 
https://docs.python.org/3/library/functions.html#all and have you tried 
any of them with the interactive interpreter?

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence



More information about the Tutor mailing list