How to exit all while True

while True:         #This is an infinite loop. If you want to quit, you can only exit layer by layer. For example, if you enter quit at the third layer, it will return to the second layer. Is there any way to exit all at the third layer?
     print ( " level1 " )
    choice = input( " Please enter your choice: " )
     if choice == " quit " : break 
    while True:
         print ( " level2 " )
        choice = input( " Please enter your choice: " )
         if choice == " quit " : break 
        while True:
             print ( " level3 " )
            choice = input( " Please enter your choice: " )
             if choice == " quit " : break
tag = True
 while tag:    #Assign True to the tag, once the condition is not met, the while loop will not be executed. Remember to 
    print ( " level1 " )
    choice = input( " Please enter your choice: " )
     if choice == " quit " : break 
    if choice == " quit_all " : tag = False   #Add this if condition to each loop 
    while tag:
         print ( " level2 " )
        choice = input("请输入你的选择: ")
        if choice == "quit": break
        if choice == "quit_all": tag = False
        while tag:
            print("level3")
            choice = input( " Please enter your choice: " )
             if choice == " quit " : break 
            if choice == " quit_all " : tag = False

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326529794&siteId=291194637