[Tutor] list method help

Michael Haft m.haft at abdn.ac.uk
Thu Feb 2 14:50:49 CET 2006



Hello,
          was just trying to do something and tried the following code:

list = ["1", "test", "1.5"]

for x in list:
     print list.pop(x)

I get the following error:

print list.pop(x)
TypeError: an integer is required

Does this mean i can't use a for loop to pop things from a list? or is 
there another way to do it?

I also tried the following:

list = ["1", "test", "1.5"]

for x in list:
     print list.pop(0)

which worked but returned the following:

1
test

Why did it not return the last value in the list?

Thanks

Mike

------------
Michael Haft
School of Biological Sciences
Plant & Soil Science
Cruickshank Building
St.Machar Drive
Aberdeen AB24 3UU
E-mail: m.haft at abdn.ac.uk



More information about the Tutor mailing list