superpollo wrote:
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?

'enumerate' is the Pythonic solution.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to