Python循环到错误的点

2024-04-26 17:32:25 发布

您现在位置:Python中文网/ 问答频道 /正文

在python3.3中,我制作了一个包含两个while true的游戏,当我运行它时,它会循环到第一个while true而不是第二个while true。为什么会这样? 我的第一部分代码如下:

while True:
   # Callum Dashfield
   print ("You must answer all questions in block capitals")
   print ("Welcome to maze runner")
   print ("To learn about the controls press C")
   print ("To learn the about the different types T")
   print ("To play press START")
   run = input ()
   #Controls
   if run == "C":
      print ("To attack press H")
      print ("To walk forward press W")
      print ("To turn left press A")
      print ("To turn right press D")
      print ("To turn around press S")
      print ("To block press B")
      print ("To see what you are carrying press E")
      print ("To open stats press Q")
      print ("To open this screen press C")
      print ("To go back to the main menu press M")
      return_to_menu = input()
      if return_to_menu != "M":
         break

这是第二个循环:

while True:
   solider_close = ['7', '8' , '9', '10']
   from random import choice
   solider_long = ['1', '2', '3']
   from random import choice
   solider_speed = [ '4', '5', '6']
   from random import choice 
   solider_block = [ '4', '5', '6']            
   print ("You choose solider")
   print ("Your stats: close combat - " + choice(solider_close))
   print ("            long range combat - " + choice(solider_long))
   print ("            long range combat - " + choice(solider_speed))
   print ("            long range combat - " + choice(solider_block))
   print ("Press S to continue")
   continues = input ()
   if continues == "Y":
   #RESET  
   else:
      break

Tags: thetotrueinputifblocklongturn