n = [3, 5, 7]
def double_list(x):
for i in range(0, len(x)):
x[i] = x[i] * 2
return x
print double_list(x)
The double_list call on the last line is giving me a SyntaxError.
n = [3, 5, 7]
def double_list(x):
for i in range(0, len(x)):
x[i] = x[i] * 2
return x
print double_list(x)
The double_list call on the last line is giving me a SyntaxError.
In Python 3, the print syntax has been changed in order to bring more consistency with the rest of the Python syntax, which uses the brackets notation to call a function.
You must always do print(....) with the brackets, hence the SyntaxError.
print(double_list(x))
However, I do not see the rest of your code, so maybe you also have another iterable called x.
Otherwise you must also replace x by n, to avoid getting a NameError this time.
What is x in double_list(x), and why do you think it has that value?
Did you mean double_list(n)?