Python List help

#Write your function here

def delete_starting_evens(lst):

while (len(lst) > 0 and lst[0] % 2 == 0):

lst = lst[1:]

return lst

#Uncomment the lines below when your function is done

print(delete_starting_evens([4, 8, 10, 11, 12, 15]))

print(delete_starting_evens([4, 8, 10]))

MY QUESTION:

What dictates this code to repeat through each number in the list?
Thanks!

the while loop. The while loop will keep running while the two conditions are met:

there are elements in the lst
the first element in the list is even.

1 Like

Thanks so much, really helped me out.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.