It seems like I got into a problem and I cannot understand where my problem is and why it’s happening.
Write a function called
delete_starting_evens() that has a parameter named
The function should remove elements from the front of
lst until the front of the list is not even. The function should then return
For example if
lst started as
[4, 8, 10, 11, 12, 15] , then
delete_starting_evens(lst) should return
[11, 12, 15] .
Make sure your function works even if every element in the list is even!
for num in lst:
if num % 2 == 0 and len(lst) > 0: lst.remove(num) elif num % 2 != 0: break
The program just skips on 8 and doesn’t break when it meets the number 11.
Thanks for your help