inbalid syntax求救
我自己做了个东西,然后又老是显示invalid syntax,不知道怎么回事,求大佬帮忙print(---------------1---------------)
temp = input("Who are you")
= int(temp)
if guess == king
print("Oh,I forgot it.Come here.")
print("Let me have a look.")
else:
print("NO NO NO")
print("You died") 本帖最后由 Hello. 于 2020-7-24 23:19 编辑
print(---------------1---------------)
temp = input("Who are you")
= int(temp) # What's this?
if guess == king
print("Oh,I forgot it.Come here.")
print("Let me have a look.")
else:
print("NO NO NO")
print("You died")
这么改!
print("---------------1---------------")
temp = input("Who are you")
guess = temp
if guess == "king":
print("Oh,I forgot it.Come here.")
print("Let me have a look.")
else:
print("NO NO NO")
print("You died") 发错了,这个才是
print(---------------1---------------)
temp = input("Who are you")
guess = int(temp)
if guess == king:
print("Oh,I forgot it.Come here.")
print("Let me have a look.")
else:
print("NO NO NO")
print("You died")
nolight 发表于 2020-7-24 23:16
发错了,这个才是
print(---------------1---------------)
temp = input("Who are you")
看楼上!!! 第一句print里面并没有---------1-----------这个变量,第四句你并没有定义king这个变量 代码的错误挺多的……
[*]“---------------1---------------” 是一个字符串,所以两边要加上英文半角引号
[*]int(temp) 要赋值给什么变量?你这都没写,等号前面是空的
[*]if 语句后面一定要跟冒号
这样就可以了:
print('---------------1---------------')
temp = input("Who are you")
guess = int(temp)
if guess == king:
print("Oh,I forgot it.Come here.")
print("Let me have a look.")
else:
print("NO NO NO")
print("You died") 没问题了,实在感谢{:10_254:} nolight 发表于 2020-7-25 13:07
没问题了,实在感谢
static/image/hrline/1.gifhttp://m.qpic.cn/psc?/V1046bnt0Whegz/xBqlYxewEGhxwKHKc.e8gWETCXv5ZK9R3sW45wLTg4brxbi1sq8apht8yP2udPC5hWrC4YpaGIDqN2J4a*A1HIXyApe5Vod0pQ*kC.PS7wg!/b&bo=jgWAAjYHPwMDGTg!&rf=viewer_4&t=5
如果帮到你了,设置下最佳可好呀{:10_297:}
本帖最后由 石泊远 于 2020-7-25 22:50 编辑
首先第一句你并没有定义---------------1--------------,所以需要加上引号
还有,if后一定要加冒号
第三句我想应该是这样的:
guess = int(temp)
但是,上面可以改为这样
guess = int(input('Who are you'))
第四句你并没有定义king,所以需要加上引号
print(---------------1---------------)#错误
temp = input('Who are you')
= int(temp) #错误
if guess == 'king'
print("Oh,I forgot it.Come here.")
print("Let me have a look.")
else:
print("NO NO NO")
print("You died")
|||
|||
\/ \/ \/
print('---------------1---------------')
guess = int(input('Who are you')) #改
if guess == 'king':
print("Oh,I forgot it.Come here.")
print("Let me have a look.")
else:
print("NO NO NO")
print("You died")
页:
[1]