语法错误 - 坚果

时间:2012-10-09 23:25:17

标签: python

stupid syntax error!

我无法弄清楚这些代码的问题是什么。如果我打印“x是最高的奇数”,它工作正常,但每当我试图打印'x'的实际值时,我得到一个语法错误。我错过了一个小而简单的步骤?

谢谢!

2 个答案:

答案 0 :(得分:2)

试试这个:

print x, 'is the highest odd number'

或者如果您使用的是Python 3:

print(x, 'is the highest odd number')

答案 1 :(得分:1)

 print(x, "is the highest odd number")

python3 syntax for print

没有逗号:

x "is the highest odd number"

是一个数字和一个没有运算符的字符串,因此语法错误。

同样,评估2"a"会给您一个语法错误。

相关问题