【发布时间】:2017-12-21 03:25:59
【问题描述】:
import time
print("hello, do you want to play this detective game?")
choice == input( "Yes or no?")
if choice 'no' :
print: "ok then, bye"
exit
if choice'yes':
start
name == input("Enter your name")
print("hello, " + name ", in this game you are a famous detective handling a theft case."
time.sleep(1)
print(" you have gone on a holiday but ended up lost in the forest. you see a man walking up to you")
time.sleep(1)
print ("man:' hi there! you seem quite lost! Do you want to stay the night with me?'")
print(" you said:'why should i? i dont even know you'")
print(" man : ' Do as you please, but if you stay in the forest for the night here's a friendly warning: there's wild wolves in the forests.'")
choose == input( "stay the night or refuse?" )
if choose "refuse":
print("man: ' boy, you are stubborn!")
print( "the man walks away, leaving you behind" + " In the end, you got eaten by the wolves due to your stubborness. THE END")
choice == input("do you want to play again? yes or no?")
if choice "yes":
start
if choice "no":
print( "ok then, bye!")
exit
基本上我的问题是上面的“无效语法”[你想玩吗? ] '不' 回应。
但是当我删除它时,问题转到下一行。这很烦人,我找不到解决方法。
我尝试在 ' 和 " 之间进行更改,但结果仍然相同。
如果你们中的任何人愿意花时间回复我,我昨天刚开始,但对无效语法仍然不是很清楚,我会很高兴。
【问题讨论】:
-
你需要在这条线上加上一个右括号吗?
print("hello, " + name ", in this game you are a famous detective handling a theft case."- 为什么这不像您的其他打印语句?print: "ok then, bye"--- 基本上你需要很多在输入准确你要复制的内容时更加小心。关闭还不够好。你需要准确。 -
太多错误的语法我会推荐pycharm或任何其他IDE
-
您的代码有许多非常基本的错误。有些行远非 Python。抱歉,我想您将不得不再次阅读本教程。
标签: python python-3.x syntax