Ive been working on this little piece of code down there that removes the odd numbers from a list of numbers. I get an "IndexError: list index out of range" whenever I try to run it. From what I understand, it means that l is attempting to use the number at position i that doesn't exist.
def del_odd(l): for i in range(0,len(l)): if l[i]%2 != 0: l.remove(l[i]) return l
I may have completely misunderstood the error, but could someone offer up a small nugget of wisdom?
It might be a tall order, but try to just point me in the right direction instead of just giving me the code outright as I still want to try to learn this myself.