I am completely lost on this due mostly to not understanding that index values can be set through a variable. Being that I have been unable to solve this myself, I copied the cheater results and examined them line for line (though I’ll try again without help tomorrow):
1 #Write your function here
2
3 # Define function ‘double_index’ and it’s variables ‘lst’ and ‘index’
4 def double_index(lst, index):
5
6 # Check to see that variable ‘index’ is equal to or greater than the number of entries in the variable ‘lst’ (defined as a list in the final print statement, but from now on referred to as ‘list’ instead of ‘variable’), and if so, return the list ‘lst’ as is
7 if index >= len(lst):
8 return lst
9
10 # In case the variable ‘index’ is lower than the number of entries in list ‘lst’, execute the following commands
11 else:
12
13 # Create a new variable that takes it’s value from list ‘lst’ from the first entry up to, but not including the entry taking it’s value from variable ‘index’
14 new_lst = lst[0:index]
15
16 # Multiply the entry specified in variable ‘index’ by 2 and append to list ‘new_list’
17 new_lst.append(lst[index]*2)
18
19 # Redifine ‘new_list’ as previously stated ‘new_list’ appended with list ‘lst’ from the entry specified in variable ‘index’ to the final entry and return the results
20 new_lst = new_lst + lst[index+1:]
21 return new_lst
22
23 #Uncomment the line below when your function is done
24
25 # Define as list and define entries for variable ‘lst’ and define value of variable ‘index’ for function ‘double_index’ and print the results of function ‘double_index’
26 print(double_index([3, 8, -10, 12], 2))
Sorry if the structure in my comments is strange, but I understand it (I think).