I really need help understanding this exercise. I am completely lost to what is happening in the syntax. I’ve done well up until this point. I need someone to explain to what is happening in this code from start to bottom and thoroughly.
This is the solution to the portal, however I don’t get what is happening after the if statement.
- What is happening when we use lst[index] as a variable?
- Why are we using the index inside of which are meant for list (if I am correct)?
I DON’T KNOW I’M JUST SUPER CONFUSED!!!
#Write your function here
def double_index(lst, index):
if index < len(lst):
lst[index] = lst[index] * 2
#Uncomment the line below when your function is done
print(double_index([3, 8, -10, 12], 2))