One of the problems is that i is an item from a list, not an index. Therefore, when you make del fiblist[i] , you are not deleting i , but a value that is in index i (which is not there, so you get an error message). This can be fixed using enumerate() to use indexes, however this leads to a new problem.
The main problem here is that you cannot change the length of the list while iterating over as it mixes with iteration in Python. One solution would be to copy the list and work on the copy, but it is best to use the list description to do what you want:
[i for i in fiblist if i%2 == 0]
This creates a new list with only the items you want. The meaning of the list is a powerful tool, so I suggest you watch the video that I linked for more.
source share