Hello: I have a problem, I found a solution to the problem in this Link
It is the 3rd question for loops coding challenge in python. The prompt in question is as follow
Write a function called delete_starting_evens() that has a parameter named lst. The function should remove elements from the front of lst until the front of the list is not even. The function should then return lst. 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!
I found a solution that gave me an output that the system greenlit, but I think the while loop I’m trying to use is not actually iterating through the list items. And In the body of the loop I’m just slicing the list through the range I’m providing.
#Write your function here def delete_starting_evens(lst): while len(lst)> 1 and lst % 2 == 0: lst = lst[3:] 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]))
I think that in my ‘’’ lst = lst[3:] ‘’’ snippet I am actually just slicing the list at that index value. Although The output met the requirements. I don’t think it’s the right code. Cuz it’s just cutting off the list at the range value. As I decreased the index value. And the list got sliced at that index value. Even though, In my view it should not.