[Tutor] walking a list
Kirk Bailey
deliberatus@my995internet.com
Wed, 12 Dec 2001 02:17:43 -0500
Ok, let's walk through a list.
I created a file, testlist.txt, with several addresses in it.
did this:
f1=open('testlist.txt','r')
members = f1.readlines()
f1.close()
type(members)
>>>type<list>
>>>|
Sokay, now try to walk it in a for loop:
for i in members:
print members[1]
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?
--
Respectfully,
-Kirk D Bailey (C)2001
Addme! icq #27840081
end
Within the sweep of his sword, Each man is an Ubar.
http://www.howlermonkey.net/
http://www.sacredelectron.org/