this code still true and more simple but not same as answer so not be accepted
def double_index(lst, index):
if index<=len(lst):
lst[index]=lst[index]*2
return lst
if index>len(lst):
return lst
this code still true and more simple but not same as answer so not be accepted
def double_index(lst, index):
if index<=len(lst):
lst[index]=lst[index]*2
return lst
if index>len(lst):
return lst
not true, you missed a corner case:
def double_index(lst, index):
if index<=len(lst):
lst[index]=lst[index]*2
return lst
if index>len(lst):
return lst
print(double_index([4, 6, 8], 3))
there are 3 elements in the list, so the highest index is 2. So when i pass 3 as second argument (for index parameter), i expect the list unmodified, i get an error
once you fix this, your code should be accepted
One other thing. The instructions for this challenge specify that you are to return a new list. You shouldn’t be mutating the original list.
From the challenge instructions: