[Tutor] all( ) built in function

Manprit Singh manpritsinghece at gmail.com
Wed Oct 14 19:09:16 EDT 2020


Dear all,

I have written my first mail with the same subject after trying it on an
interactive python shell. The answers are the same as given in the mail.
Just need to check my understanding about this function.
Regards
Manprit Singh

On Thu, Oct 15, 2020 at 4:33 AM Mark Lawrence <breamoreboy at gmail.com> wrote:

> 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
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list