0

I am making a game in python 3.3 and am using while True: and break to make a loop this is while True: print ("") 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 while True: if run == "C": 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 open pack press E") print ("To open stats Press Q") print ("To go back to the main menu press M") return_to_main_menu = input () if return_to_main_menu != "M": break else: break

Is there a way to get the break after else to go back to the second while true and also to get the break after the if to go back to the first while true

dashernasher
  • 37
  • 2
  • 12
  • 1
    possible duplicate of [Naming Loops in Python](http://stackoverflow.com/questions/8419796/naming-loops-in-python) – Joe Oct 29 '13 at 10:30
  • This is a common problem. I've found (and marked as duplicate) the equivalent Python question. Take a look at that. – Joe Oct 29 '13 at 10:31

2 Answers2

0

Either combine boolean flags and breaks or wrap loop in try: except: ... and raise an exception instead of loop. Second option probably is not that efficient but can be simpler and more reliable then tinkering with boolean flags.

peroksid
  • 890
  • 6
  • 17
0

Not like you do it.

Restructure your code so that everything in the inner loop is in a function.

Mailerdaimon
  • 6,003
  • 3
  • 35
  • 46