hi guys, i had some trouble with this too but i think i figured it out. the instructions may be a bit misleading but essentially, our job is to remove all the even numbers in “lst” before the first odd number.
def delete_starting_evens(lst): while (len(lst) > 0 and lst % 2 == 0): lst = lst[1:] return lst print(delete_starting_evens([4, 8, 10, 11, 12, 15])) #prints [11, 12, 15] print(delete_starting_evens([2, 4, 5, 8, 10])) #prints [5, 8, 10]
the condition for the While loop to be active is when the len(lst) is greater then 0 and lst is divisible by two.
when active, the purpose of the While loop is to “reset” the parameter variable “lst” as lst[1:], which is the 1st element onwards, because the 0th element is divisible by 2 so it is left out.
this happens repeatedly until the While loop hits the first odd number in “lst”, then the function ends.
notice that the indent for “return lst” is flushed with the while loop. this means that if the given list of numbers starts with an odd number right off the bat, it will return the original lst. otherwise, this will return the remaining list inclusive of the first odd number and the rest of the numbers behind it (regardless odd or even).
please correct me if I am found to be wrong! I’m just happy to see that I’m not the only confused one around here.