There is a discussion of how C and Python handle integers, and explains why n++ does not make sense in Python. See:
http://www.daniweb.com/tutorials/tutorial32575.html
Editor's note: this tutorial has been send to the doghouse as utter kaka junk!
In your corrected code this would work fine ...
list = [('mark', 'jacky','jane'),('stick','cheri','nice'),('elly','younces','pluto')]
n = 0
for i in list:
print n, i
n += 1 # replaces C's n++
If you want to pick the list of tuples really appart, then use this ...
list = [('mark', 'jacky','jane'),('stick','cheri','nice'),('elly','younces','pluto')]
n = 0
for t in list:
m = 0
for i in t:
print n, m, i
m += 1
n += 1
"""
0 0 mark
0 1 jacky
0 2 jane
1 0 stick
1 1 cheri
1 2 nice
2 0 elly
2 1 younces
2 2 pluto
"""
This gives you the index of the tuple, followed by the index in the tuple, then the value.
vegaseat
DaniWeb's Hypocrite
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417