从零开始Python 002语法错误
本帖最后由 苔草青鱼 于 2017-5-17 16:19 编辑就是那个很简单的游戏
print("!")
temp = input("guess the number")
guess = int(temp)
if guess == 9;
print("right")
else
print("no")
print("over")
运行的时候invalid syntax。然后 那个9后面标红了
用的版本是3 首先你来错板块了
其次;不是用在这里,一般是省略的
print("!")
temp = input("guess the number")
guess = int(temp)
if guess == 9:
print("right")
else:
print("no")
print("over")
print("!")
temp = input("guess the number")
guess = int(temp)
if guess == 9:
print("right")
else:
print("no")
print("over")
主要是你的“:”没有用好,你输成“;”号了,导致的错误。在if和else后面要正确使用“:”符号。如上图所示
页:
[1]