0

I keep getting a Syntax error when I type:

def someFunction(a, b):
    print(a+b)
someFunction(12, 451)

then it says:

File"<stdin>", line 3
           someFunction()
                 Syntax Error

I really appreciate any guidance! Thank you so much! (I am using Python 2.7.5)

0

2 Answers 2

3

If I had to guess, you are in the Python interpreter and wrote this:

>>> def someFunction(a, b):
...     print(a+b)
... someFunction(12, 451)
  File "<stdin>", line 3
    someFunction(12, 451)
               ^
SyntaxError: invalid syntax
>>>

You need to put one more newline after the print line:

>>> def someFunction(a, b):
...     print(a+b)
...
>>> someFunction(12, 451)
463
>>>
Sign up to request clarification or add additional context in comments.

Comments

1

In the interactive interpreter, you need one more newline after a block.

Only put new expressions or statements on the next >>> prompt:

>>> def someFunction(a, b):
...     print(a+b)
... 
>>> someFunction(12, 451)
463

Here, I hit ENTER on the empty ... line to 'close' the function.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.