Why am I getting a syntax error in python using Eclipse? [duplicate]

て烟熏妆下的殇ゞ 提交于 2019-12-26 04:23:05

问题


Edit: PYTHON 2.6 ... so not technically a duplicate question .....

I'm trying to figure out how to use Python on Eclipe using this tutorial but I'm stuck on part 4.Debugging. using this code:

def add(a,b):
    return a+b

def addFixedValue(a):
        y = 5
        return y +a

print add(1,2)
print addFixedValue(1)

I added a breakpoint, but still get an error:

    print add(1,2)
            ^
SyntaxError: invalid syntax


回答1:


Your code is correct according to python 2.

As you are getting syntax error, you must be using python 3. In that case, you need to add parenthesis around print statement

print (add(1,2))


来源:https://stackoverflow.com/questions/41111702/why-am-i-getting-a-syntax-error-in-python-using-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!