Why do I get an index error with this code?

why my code doesn’t work

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

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

We need to check the length before attempting to access the list element in case the list is empty, whereby lst[0] will raise an exception.

>>> lst = [4, 8, 10, 11, 12, 15]
>>> lst = lst.remove(lst[0])
>>> lst

That doesn’t look right. Are you sure you are using the .remove() method as intended?

def odd_indices(1st):

new_list =

for index in range(1, len(1st),2)


I am getting the following error:
File “script.py”, line 2
def odd_indices(1st):
SyntaxError: invalid syntax

please help.

HI @ajax2635947798,

Your error is caused by attempting to 1st as the name for a parameter. Your name can include integer numbers but it can’t start with one.

It’s worth having a look at this FAQ which will help if you ever post code the future (covers fromatting and indentation).