10. Modifying an element of a list in a function


#1

https://www.codecademy.com/courses/learn-python/lessons/lists-and-functions/exercises/modifying-an-element-of-a-list-in-a-function?action=lesson_resume&link_content_target=interstitial_lesson

<In what way does your code behave incorrectly? Include ALL error messages.>
File “python”, line 2
SyntaxError: can’t assign to literal

why is it saying this?

def list_function(x):
  1, x[1] = x[1] + 3
  return x

n = [3, 5, 7]
print list_function(n)

#2

this line:

1, x[1] = x[1] + 3

why do you have 1, at the beginning? It isn’t part of the assignment, i recommend to remove it


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.