misterwolfy
10-22-2011, 02:55 PM
I can't figure out why this is wrong. What I want is to end up with just 'k' in the list. Instead I get an out of range error.
What I would expect is that it would count letters, 11 total, then cycle through them printing and removing until only k was left, but maybe the idex changes everytime an item is removed.
letters = ['a','b','c','d','e','f','g','h','i','j','k']
for i in range(10):
print ("this letter is: " + letters[i] )
letters.remove(letters[i])
print letters
Any help? Thanks for reading!
What I would expect is that it would count letters, 11 total, then cycle through them printing and removing until only k was left, but maybe the idex changes everytime an item is removed.
letters = ['a','b','c','d','e','f','g','h','i','j','k']
for i in range(10):
print ("this letter is: " + letters[i] )
letters.remove(letters[i])
print letters
Any help? Thanks for reading!
