Last answered:

05 Apr 2020

Posted on:

05 Apr 2020

0

Use indentation properly to print the result of the function with an argument of 3. (Python 2)

   
def ten(x):
    x=10
    return x
print ten(3)
output:
  File "<ipython-input-1-9fb8d4762a52>", line 4
    print ten(3)
            ^
SyntaxError: invalid syntax

After restarting the kernel, result is same the syntax error is occurred. Please help me out of this.
def ten(x):
    x=10
    return x
print ten(3)

OUTPUT:
  File "<ipython-input-1-9fb8d4762a52>", line 4
    print ten(3)
            ^
SyntaxError: invalid syntax
1 answers ( 0 marked as helpful)
Posted on:

05 Apr 2020

1

Please add indentation before print statement. It will work .:)

Your code:-

def ten(x):
    x=10
    return x

print ten(3)           [This statement should be indented]

 

Correct code:-

def ten(x):
    x=10
    return x
    print ten(3)    [Indented properly]

 

hope it helps!
Have a good day!:) :)


 

Submit an answer