0

How can i manipulate python dictionaries

i am making a program which prints requirements for joining teams each team has two sub teams ive used simple dictionaries for the main team but dont know how to incorporate the sub teams what i now want is to ask the user to select the subteam of the selected team in order to print the sub teams requirements i dont know if i should create another dictionary or is there some kinda subdictionary

8th Feb 2017, 3:47 PM
Prince Kelvin
Prince Kelvin - avatar
4 Answers
0
I don't think I got your question right, but if I did, your solution is to make nested dictionaries: teams = { team_one = { subteam_one = description1, subteam_two = description2 }, team_two = { subteam_one = description3, subteam_two = description4 } } for example, teams[team_one][subteam_two] returns description2, and so on.
8th Feb 2017, 7:12 PM
DotJason
0
i have two teams(a) and team(b) each of my teams has two subteams i. e team(a) has subteams(b)and(c) and so with team(b) each of the subteams has their different enrollment requirements. i want to prompt a user to first of all enter the name of the team he wants to enroll in after that he is then provided with the subteams option for him to select before he can now see the selected subteam's requirements.
8th Feb 2017, 9:10 PM
Prince Kelvin
Prince Kelvin - avatar
0
so teams[team_one], for example, returns a dictionary of subteams of team 1 and their requirements. You can iterate through the keys to get a list of all subteams' names
9th Feb 2017, 3:54 AM
DotJason
0
am receiving a syntax error while using nested dictionaries as suggested by Vfeafanov maybe you can give me the code at the play ground. i want something like this: footwears={shoes={'high heels': '6inches, 12inches, 'flat shoes': '2inches, '1inch'} print 'choose your foot wear' answer = input #in this case i type shoes if answer in footwears: #yes cos i chose shoes print (high heels or flat shoes) choice = input #Here i choose high heels print(footwears[choice]) here is just an example of what i want pls.
9th Feb 2017, 10:04 AM
Prince Kelvin
Prince Kelvin - avatar