count in 'for ... in ...'
Cliff Wells
logiplexsoftware at earthlink.net
Fri Nov 9 17:59:56 EST 2001
On Friday 09 November 2001 14:37, DeVerter at robinsonmechanical.com wrote:
> Try this.
>
> for s in my_list:
> print my_list.index(s), ".", s
>
> This way you don't need a counter variable.
>
I'm guessing that list.index() does a linear search through the list, so this
would degrade performance pretty badly. Additionally, if there are duplicate
items in the list, you'll get the first one every time.
Regards,
--
Cliff Wells
Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 x308
(800) 735-0555 x308
More information about the Python-list
mailing list