[Tutor] Counting matching elements in sequences

Karl Pflästerer sigurd at 12move.de
Tue Dec 9 15:42:09 EST 2003


On  9 Dec 2003, Gregor Lingl <- glingl at aon.at wrote:

> What do you think about:

>  >>> def alleq(seq):
> ...     return seq == seq[:1]*len(seq)
> ...

Cool.  But the for loop is the best one I think since you only traverse
the sequence until you find a difference and since you don't have to
build a second list and have to use len() on the original sequence.

   Karl
-- 
Please do *not* send copies of replies to me.
I read the list




More information about the Tutor mailing list