[Tutor] walking a list
Sean 'Shaleh' Perry
Tue, 11 Dec 2001 23:39:45 -0800 (PST)
> Sokay, now try to walk it in a for loop:
> for i in members:
> print members
> Gets this error:
> Traceback (most recent call last):
> File "<pyshell#119>", line 2, in ?
> print members[i]
> TypeError: sequence index must be integer
> ok, how do I get it to walk through a loop, performing a block of code
> for each item in the list?
>>> l = ['s', 't', 'r']
>>> for i in l:
... print type(i)
hope this makes shows the error of your ways.