[英]Running python in terminal in vs code gives me a syntax error, however, manually selecting the code and running it does not give me the syntax error
[英]python shell gives syntax error when running a print() ,however the same code executes in jupytr notebook
def test_number(x, y):
if x == y or abs(x-y) == 5 or (x+y) == 5:
return True
else:
return False
print(test_number(7, 2))
print(test_number(3, 2))
print(test_number(2, 2))
在 jupyter notebook 中运行时,在 python shell cmd 中运行时以 O/P:True 执行,它给出了无效的语法
错误在标识中。 Python 是 ident 基础语言。 正确的例子。
def test_number(x, y):
return x == y or abs(x-y) == 5 or (x+y) == 5
print(test_number(7, 2))
print(test_number(3, 2))
print(test_number(2, 2))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.