def list_function(x):
return x[1] += 3
I want to do this, but apparently I can't. I understand I can do this
x[1] += 3
return x
but, I wanted to keep it on a single line. Does return always need to be on its own line, and if not, why does it need to be in this particular case?
x[1] += 3is not an expression, it's a complete statement and thus belongs to its own linereturn (x[1] += 3). Thanks for the help!return x[1] += 3;is valid C code, but it's equivalent tox[1] += 3; return x[1];.