Thanks guys for the help on this. As it turns out I have learned new
commands as a result of the question: all() and any() will work perfectly!
The other solutions, as always, are enlightening. And, no, Chris, this is
not homework :)

On Tue, Jan 8, 2019 at 9:31 AM Neil Cerutti <ne...@norwich.edu> wrote:

> On 2019-01-08, MRAB <pyt...@mrabarnett.plus.com> wrote:
> > On 2019-01-08 00:47, i...@koeln.ccc.de wrote:
> >> You might do something like
> >>
> >>      if len(a) == 0 or all(i == a[0] for i in a[1:]):
> >>
> > You don't need to check the length of the list because if the list is
> > empty, 'all' will return True anyway.
>
> Neat! I expected that a[0] would be executed in that case,
> but it is not.
>
> --
> Neil Cerutti
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

**** Listen to my FREE CD at http://www.mellowood.ca/music/cedars ****
Bob van der Poel ** Wynndel, British Columbia, CANADA **
EMAIL: b...@mellowood.ca
WWW:   http://www.mellowood.ca
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to