hi clp.

i want to get from here:

nomi = ["one", "two", "three"]

to here:

0 - one
1 - two
2 - three

i found two ways:

first way:

for i in range(len(nomi)):
    print i, "-", nomi[i]

or second way:

for (i, e) in enumerate(nomi):
    print i, "-", e

which one is "better"? is there a more pythonic way to do it?

bye

ps:

m...@192.168.1.102:~/test$ python -V
Python 2.3.4
m...@192.168.1.102:~/test$ uname -a
Linux fisso 2.4.24 #1 Thu Feb 12 19:49:02 CET 2004 i686 GNU/Linux
m...@192.168.1.102:~/test$
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to