Python job Two: Level three list

Source: Internet
Author: User

Job Two: Multilevel menu
Requirements:
1. Level Three Menu
2. You can choose to go to each submenu and return to the parent menu.
3. New knowledge points required: list, dictionary

Logic:
Print Provincial provincial selection whileinput_s = ="B": Print ProvincialElse: Judging provincial input and print city -level selection whileInput_c = ="B": Print ProvincialElse: Judge City-level input and print county-level selection whileinput_x = ="B": Print City levelElse: Judge County input print County number

Code implementation:

1 #Initializing System Tags2Input_s_flag = 0#provincial selection is correctly marked3Input_c_flag =04Input_x_flag =05input_s =""6Input_c =""7input_x =""8 9 #Initialize OutputTen Print("Provincial unit: Return to Superior: B") One Print(Dest.keys ())#Print Provincial Ainput_s = input ("Please select the provincial unit name:")#Provincial Selection -  -  whileInput_s.upper () = ="B":#Print Provincial the     Print("Provincial unit: Return to Superior: B") -     Print(Dest.keys ()) -input_s = input ("Please select the provincial unit name:") - Else:#Print City level +      forSsinchDest.keys ():#determine whether provincial selection is correct -         ifSS = =input_s: +Input_s_flag = 1 A              Break at     Else: -Input_s_flag =0 -      whileInput_s_flag = =0: -input_s = input ("input Error, please select the provincial unit name: \ n") -          forSsinchDest.keys ():#determine whether provincial selection is correct -             ifSS = =input_s: inInput_s_flag = 1 -                  Break to         Else: +Input_s_flag =0 -     ifInput_s_flag = = 1: the         Print("City-level units: Return to Superior: B") *         Print(Dest[input_s].keys ())#Print City level $Input_c = input ("Please select a city-level unit name:")#City-Level selectionPanax Notoginseng          whileInput_c.upper () = ="B": -             Print("Provincial unit: Return to Superior: B") the             Print(Dest.keys ()) +input_s = input ("Please select the provincial unit name:") A         Else: the              forCcinchDest[input_s].keys ():#determine whether the city-level selection is correct +                 ifCC = =Input_c: -Input_c_flag = 1 $                      Break $             Else: -Input_c_flag =0 -              whileInput_c_flag = =0: theInput_c = input ("wrong input, please select the city level unit name: \ n") -                  forCcinchDest.keys ():#determine whether the city-level selection is correctWuyi                     ifCC = =Input_c: theInput_c_flag = 1 -                          Break Wu                 Else: -Input_c_flag =0 About             ifInput_c_flag = = 1: $                 Print("County Unit: Return to Superior: B") -                 Print(Dest[input_s][input_c])#Print County -input_x = input ("Please select the county unit name:")#County Selection -                  whileInput_x.upper () = ="B": A                     Print("City-level units: Return to Superior: B") +                     Print(Dest[input_s].keys ())#Print City level theInput_c = input ("Please select a city-level unit name:")#City-Level selection -                 Else: $                      forXxinchDest[input_s][input_c]: the                         ifxx = =input_x: theInput_x_flag = 1 the                              Break the                     Else: -Input_x_flag =0 in                      whileInput_x_flag = =0: theinput_x = input ("input error, please select County-level unit name: \ n") the                          forXxinchDest[input_s][input_c]:#determine whether county-level selection is correct About                             ifxx = =input_x: theInput_x_flag = 1 the                                  Break the                         Else: +Input_x_flag =0 -                     ifInput_x_flag = = 1: the                         Print("The number of the%x you have selected is:"%input_x)Bayi                         Print("back to top level: B") the                         Print(Dest[input_s][input_c].index (%x)%input_x)

Python job Two: Level three list

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.