 # Why doesn't my solution work - code challenge lists

The Double Index code challenge didn’t accept my code and I don’t know why. Below is my code I used:

def double_index(lst, index):
if index > len(lst):
return lst
else:
lst[index] = 2 * lst[index]
return lst

#Uncomment the line below when your function is done
print(double_index([3, 8, -10, 12], 2))

OUTPUT: [3, 8, -20, 12]

Changed the validation to the following:
print(double_index([3, 8, -10, 12], 5))

The index of 5 is greater than the length of the list which only has 4(0, 1, 2, 3)

OUTPUT: [3, 8, -10, 12]

The outputs matched what was expected for both scenarios.

So the main problem with this code is the line `if index > len(lst):`
for example if the list is `[0, 1, 2, 3]` then `len(list) = 4`
The problem here is that an index of 4 would get passed in correctly but return an error as the list doesn’t have a spot 4. (remember that the list is 0 indexed) so you could fix this with either
`if index >= len(lst):` or `if index + 1 > len(lst):`