I'm trying to delete every instance of a class in a for
loop. However, there is a point in which the list length meets the for
loop iteration. See:
for n in range(len(myList)): print(len(myList), n) del myList[n]
Output:
15 0
14 1
13 2
12 3
11 4
10 5
9 6
8 7
7 8
IndexError: list assignment index out of range`
The only solution that came across my head so far was to create a variable for each item in the list and deleting them that way, but I've heard that's usually not something you need to do. Any ideas on how I can achieve this?