Skip to content

Instantly share code, notes, and snippets.

@codecademydev
Created September 18, 2019 09:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codecademydev/6c614f17727474eb0c390b393a02a462 to your computer and use it in GitHub Desktop.
Save codecademydev/6c614f17727474eb0c390b393a02a462 to your computer and use it in GitHub Desktop.
Codecademy export
#Write your function here
def double_index(lst, index):
list_until_index = lst[:index]
print(list_until_index)
list_after_index = lst[-index+1:]
print(list_after_index)
number_in_question = lst[index]
double_number_in_question = 2 * number_in_question
new_list = list(zip(list_until_index, [double_number_in_question], list_after_index))
if len(lst) > index:
return new_list
else:
return lst
#Uncomment the line below when your function is done
print(double_index([3, 8, -10, 12], 2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment