May-11-2023, 09:38 AM
A common mistake is to change a list over which one is iterating. Are you perhaps doing something like this?
mylist = ["one", "two", "three", "four"] for i in range(len(mylist)): removed_item = mylist.pop(i) print(f"Removed item {removed_item}")
Output:Removed item one
Removed item three
Error:Traceback (most recent call last):
File "/home/ibreeden/PycharmProjects/Forum/forum02.py", line 3, in <module>
removed_item = mylist.pop(i)
IndexError: pop index out of range