FAQ: Code Challenge: Loops - Delete Starting Even Numbers


I’m not sure what you disagree with or what your counter-argument is :^)


You seemed to be asking if it was reasonable.
Upon reading it, there are some things that come to mind about how it could be changed, this is without putting any thought into it, it’s a reaction.

If I write a math expression like so:


Then you’d have a similar reaction, you’d want to change it into


before doing anything else, there is no reason to write it that way. After cleaning it up, it’ll be easier to continue.

I don’t think it’s inappropriate to note that something could be written simpler, especially when at the same time motivating how it could be done.


Do you intimidate easily? That would be the only reason to shy away.

First rule in learning anything is to be able to take criticism. It’s how we learn from our peers, or future peers (the ones we see as mentors today).

Second rule in learning is never be afraid to be wrong.

Third rule is never be afraid to admit it and take note of others’ contributions in pointing it out.

Not that any accusations are being leveled here by any stretch. Just the ravings of an old man cast upon the waters.


im having a tough time learning loops, could anyone tell me why my solution doesnt work?

#Write your function here
def delete_starting_evens(lst):
if len(lst) > 0:
while lst[0] % 2 == 0:
lst = lst[1:]
return lst

I can see how checking both the len and % in one line is better but im not sure why mine doesnt work as they both look very similar

#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]))

>>> [10][1:]
>>> [][0]
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
IndexError: list index out of range

Study this as it relates to your code. The answer is in there.