-1
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.

linusg
  • 6,289
  • 4
  • 28
  • 78

2 Answers2

-1

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.

DevLounge
  • 8,313
  • 3
  • 31
  • 44
-2

What is x in double_list(x), and why do you think it has that value?

Did you mean double_list(n)?

Larry Lustig
  • 49,320
  • 14
  • 110
  • 160