Python Learning---Level three menu

Source: Internet
Author: User

Development environment:

os:64-bit Windows 7
ide:pycharm4.0.4
Python version: 2.7.10

Program Description:

A, the program realizes the function for the fans can choose their favorite team and players
b, the program a total of three levels of directory, the first level of the East and West Division, the second level for the team list under each section, the third level for the team list of players List, each player's basic information for the player play role
C, in each level of the directory, the customer can be selected in the level directory, the corresponding option, q corresponding exit the entire program, B represents back to the previous level to re-select.

Copyright Notice:

This multilevel menu program is only used for Python learning, copyright has the author, without the author's consent, may not be used for commercial use of this multilevel menu program.


#
-*-coding:utf-8-*-__author__='Bruce'levelist= { 'eastdist': { "Cavs":{ "LBJ":['F'], " Love":["C"], "iving":["S"] }, "Bulls":{ "Rose":["S"], "Gassol":["C"], "Butter":['F'] }, "Heat":{ "Wade":["S"], "Bosh":["F"], "Deng":["S"] }, }, "westdist": { "Warriors":{ "Curry":["S"], "Thompson":["S"], "Green":['F'] }, "Spurs":{ "Duncan":['F'], "Park":["S"], "Ginobili":["S"] }, "Thunders":{ "Durant":['F'], "Wesbrook":["S"], "Yibaka":["C"]},},}flag=True whileflag:Print '----------------------Partition Selection-------------------------------------' forIinchRange (len (Levelist.keys ())):PrintI,levelist.keys () [i]Print '------------------------------------------------------------------'Dictselect= Raw_input ("Select the team partition (press Q to exit):"). Strip ()Print "-------------------------Team Choose----------------------------------" #if Dictselect.isdigit (): #无法判断选项以外的其他数字, Error ifDictselect = ="0" orDictselect = ="1": Dictselect=Int (dictselect)#print Levelist.keys () [Dictselect] #取出分区名字, and the key value of the team dictionaryDictkey = Levelist.keys () [Dictselect]#Remove the partition name and the key value of the team dictionary whileflag: forJinchRange (len (levelist[dictkey)):PrintJ,levelist[dictkey].keys () [j]#print '------------------------------------------------------------------' #print Levelist[teamkey].keys () [1]Teamselect = Raw_input ("Select the team number (press Q to exit and press B to return to the previous level):"). Strip ()Print "-------------------------player Selection----------------------------------" ifteamselect.isdigit (): Teamselect=Int (teamselect) Teamkey= Levelist[dictkey].keys () [Teamselect]#Remove the team name and also the key value of the player dictionary #print Teamkey #取出球队名字 and is also the key value of the player dictionary #print Levelist[dictkey][teamkey] #取出 [partition] [team] below the player dictionary whileflag: forLinchRange (len (levelist[dictkey][teamkey)):PrintL,levelist[dictkey][teamkey].keys () [L]Print '---------------------------------------------------------------'Playerselect= Raw_input ("Select the player serial number (press Q to exit and press B to return to the previous level):"). Strip ()ifplayerselect.isdigit ():Print "In the end, please select Q to exit, or press B to return to the previous level" elifPlayerselect = ="b": Break elifPlayerselect = ="Q": Flag=False# Break Else: Print "your input is wrong, please re-enter" elifTeamselect = ="b": Break elifTeamselect = ="Q": Flag=FalseElse: Print "your input is wrong, please re-enter" elifDictselect = ="Q": Flag=FalseElse: Print "your input is wrong, please re-enter"

Python Learning---Level three menu

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.