>>> x = 15
if (x/2)*2 == x:
print ('Even')
else:
print ('Odd')
SyntaxError: multiple statements found while compiling a single statement
>>> x = 15 if (x/2)*2 == x:
print ('Even')
else:
print ('Odd')
SyntaxError: invalid syntax
最佳答案
在Python中你不能在一行中写多个语句,而是这样写
x = 15
if (x/2)*2 == x:
print ('Even')
else:
print ('Odd')
这里:
得到了
关于Python 3.3.2 在 If-else 中使用 ":"语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18013813/