10. Modifying an element of a list in a function



<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)


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


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