Modifying an element of a list in a function - unexpected indent


< error messages >
File “python”, line 3
return x
IndentationError: unexpected indent

<What do you expect to happen instead?>
n = [3, 8, 7]


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

n = [3, 5, 7]
print n

<do not remove the three backticks above>
Hi there, hm somehow I cannot find the reason why it does not work.


this two lines:

  x[1] = x[1] + 3
	return x

do not have the same indent level, they should have the same indent level


Ok, thank you. I found the reason. I had some whitespace in before “return x”.