As I was debugging a small bit of code, I noticed something unexpected:
The for loop that cycles through the filename to remove the numbers, by looking at each character of the string and replacing it, seems to take a print of the filename as it exists in the first pass of the loop and cycles through those letters, so that if, as I do in the code, make changes to the string passed to the loop, python still looks for those letters that were in the string to begin with.
Have I just uncovered (for myself) a fundamental feature of the for loop, or is this just something weird that resulted from my code?
short_list = ['1787cairo.jpg', '237398rochester.jpg']
print short_list
for entry in short_list:
entry_pos = short_list.index(entry)
for char in entry:
print entry, char, ord(char)
if ord(char) in range (48,58):
entry = entry.replace(char,'')
print entry
short_list[entry_pos] = entry
print short_list