Sir, how can we do it with for loop? Please suggest .
What are you asking? Did you skip the lesson on loops and go straight to the challenge?
Sir, can you please explain me this code. link ==https://www.codecademy.com/paths/computer-science/tracks/cspath-flow-data-iteration/modules/dspath-python-loops/lessons/python-functions-loops-cc/exercises/remove-even-nums
Please post what code you have so far.
while (len(lst) > 0 and lst % 2 == 0):
lst = lst[1:]
#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]))
Is that your code or the given solution? What is it that you do not understand?
I don’t understand how this given is working for the question given here.
It’s checking to see that the list is not empty, first, then checking the first element to see if it is even. If so, line inside the while block assigns all but the first element (a slice) back onto the
lst variable. The loop terminates if it encounters an odd number, or if the list is empty.