On 2019-01-08 00:14, Bob van der Poel wrote:
I need to see if all the items in my list are the same. I was using set()
for this, but that doesn't work if items are themselves lists. So, assuming
that a is a list of some things, the best I've been able to come up with it:

     if a.count( targ ) == len(a):

I'm somewhat afraid that this won't scale all that well. Am I missing
something?

How about this:

all(item == my_list[0] for item in my_list)
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to