这是我的剧本
name = input("Hello, to proceed please enter your name:")
print ("Hello captain %s, we have a new mission for you... its is very important. are you willing to take the risk to lead this mission?" % name)
print (50 * '-')
print ("Option 1) Yes")
print ("Option 2) No Way!")
print (50 * '-')
do_mission = input("Selct a option [1-2]:")
do_mission = int(do_mission)
if do_mission == 1:
print ("We are glad you were willing to take the job!")
elif do_mission == 2:
print ("We are sorry but we need you, if you do not accept we will have to kill you. Comprende?")
print (50 * '-')
print ("Option 1) I comprende.")
print ("option 2) I do not comprende.")
print (50 * '-')
comprende = input("Select an option [1-2]:")
comprende = int(comprende)
if comprende == 1:
print ("Good! We are glad you understand! Now, here are your instructions")
elif comprende == 2:
print ("We are sorry it had to be this way...")
print (50 * '-')
print ("GAME OVER")
print (10000 * '-')
print ("You %s are going to be our strategic thinker in this battle. We need you to think of EVERYTHING that could happen. We are going to be your eyes and ears and you are going to be our brains. EVERY decission matters, so make sure to answer carefully or bad things could happen to you and us..." % name)
print ("My final question is, are you ready to go into battle?")
print (50 * '-')
print ("Option 1) Yes!")
print ("Option 2) No!")
print (50 * '-')
battle = ("Select an option [1-2]:")
battle = int(battle)
if battle == 1:
print("You went to battle and died... Guess you should have just answered no and stayed back...")
procede_to_pass = ("Press enter to continue")
elif battle == 2:
print ("You are smart! You and your whole team lived because peace = lyfe! :D")
错误发生在第33行。我认为这是一个语法错误。感谢您的所有帮助。
答案 0 :(得分:1)
您想要输入键盘输入,其类型是整数。在python中,您可以通过下面给出的行获得整数输入,并将其存储在战斗变量中。
用这个
替换第32行和第33行 battle = int(input("Select an option [1-2]:"))