Home>

I can't solve one of the training issues.
(Problem) Define a function double (x) that returns a value that is doubled when an integer argument x is given as an argument.

double (123)
246
double (-1)
-2

File "main.py", line 4
print double (x)
^ ^
SyntaxError: invalid syntax

Corresponding source code

def double (x):
x = input ('Enter value:')
return x * 2
print double (x)

What I tried

I don't know where to put the input, and I put it above or behind, but I get an error.

Supplementary information (FW/tool version, etc.)

Please provide more detailed information here.

  • Answer # 1

    "Print double (x)" SyntaxError: invalid syntax
    Is presumed to be the environment of python 3.

    print (double (x))

    Please enclose the print target with "()".

    Full text

    def double (x):
       # ter305932
       return x * 2
    i = input ('Enter value:')
    print (double (int (i)))