Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/337.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 为什么在elif语句中使用输入时会出现语法错误?_Python_Syntax Error_Adventure - Fatal编程技术网

Python 为什么在elif语句中使用输入时会出现语法错误?

Python 为什么在elif语句中使用输入时会出现语法错误?,python,syntax-error,adventure,Python,Syntax Error,Adventure,我目前正在为一个学校项目做一个基于文本的游戏。我一直得到一个无效的语法错误的一部分,说'答复'。你知道为什么会这样吗?我在整个比赛中经常使用这种方法,这是我第一次出现这种错误 print("You decide it's time to look for a way out of this place. You consider travelling upstream to investigate where the wallet came from. You also remember bei

我目前正在为一个学校项目做一个基于文本的游戏。我一直得到一个无效的语法错误的一部分,说'答复'。你知道为什么会这样吗?我在整个比赛中经常使用这种方法,这是我第一次出现这种错误

print("You decide it's time to look for a way out of this place. You consider travelling upstream to investigate where the wallet came from. You also remember being told that all rivers will eventually lead to a town or village.")
direction = input("Do you travel a)upstream or b)downstream? >")
if direction == "upstream" or direction == "Upstream" or direction == "Up" or direction == "up" or direction == "travel upstream" or direction == "Travel upstream":
      print("You travel upstream")
elif direction == "downstream" or direction == "Downstream" or direction == "Down" or direction == "down" or direction == "travel downstream" or direction == "Travel Downstream":                                        
      print("You travel downstream. You walk for hours but the river does not lead anywhere. It gets dark and you can no longer find your way. You decide to rest until morning.")
      print("You are suddenly woken from your sleep by a familiar voice. It's your", spouse+"!")
      print(spouse_name.upper()+":", '"'+name_f+"!?",'What are you doing here?'
      reply = input("Enter 1 for 'What are you doing here??' Enter 2 for 'I don't know, I just woke up here' >")
      if reply == '1':
            print(name_f.upper()+':',"What are you doing here??")
            print(name_f.upper()+':',"I
      elif reply == '2':
            print(name_f.upper()+':',"I don't know, I just woke up here")
            print(name_f.upper()+':',"I don't remember anything, I don't remember how I got here"
      print(spouse_name.upper()+":", "How are you still alive?"
      print(name_f.upper()=':', spouse_name+',','what are you talking about??')
      print("before you have time to realise what's going on,", spouse,"pulls out a gun and shoots you in the head")
      print("GAME OVER")
在这条线上

print(name_f.upper()+':',"I
应将字符串括在两个双引号中,然后用最后一个括号结束:

print(name_f.upper()+':',"I")

在守则的这部分:

 print(name_f.upper()+':',"I
 elif reply == '2':
我想你并不是在结束打印语句或字符串,这是一项未完成的工作。 因此,代码的其余部分被视为字符串,字符串没有结尾,print语句没有右括号


程序员总是会犯这些错误,但随着您的经验越来越丰富,您需要抓住这些错误。

请给出一个答案,这里突出显示的语法已经告诉您代码无效。您以前没有关闭这行的括号…谢谢!!真不敢相信我错过了!请花点时间将您的问题格式化,使其清晰易读。这被视为是绒毛状的-参见,例如,有关此问题的另一讨论。