python 3 project - user menu for updating dictionary
EDIT REQUESTED:
I created two instances of the menu, one in a function and one outside the function because the initial test prompts the user to enter 5 jersey nums and the player rank, then expects a roster to be printed, then expects the user menu to prompt changes to the roster.
"Updating dictionary" I meant the roster is created in a dict{} and then the options of the user menu allow for editing the initial dict and then printing a new roster with the changes.
INITIAL POST:
I am having trouble with this code (class assignment, hw not test). The goal is a menu that allows the user to add and delete players from a roster, update their player rating, pull a list of the top x ratings, or simply print a roster. The assignment requires that the initial user input is 5 jersey numbers and their ratings, print a roster, then offer the user menu. I have solved the first 4 tasks. PROBLEM: when accessing menu items to add, delete, update, and rank the first roster that follows the initial 5 entries is being read as the answer instead of the roster that prints to the screen after changes are made. I can't figure out how to set it up so the roster after the initial setup is optional.
I'm hoping you will see an obvious error in the code that I'm missing. (The indentation looks a little funky to format for pasting in here. I have no indentation errors per the system.)
def print_menu():
print ('nMENU')
print ('a - Add player')
print ('d - Remove player')
print ('u - Update player rating')
print ('r - Output players above a rating')
print ('o - Output roster')
print ('q - Quit')
action_in = input('nChoose an option:n')
def output_roster():
listOFjerseys = list(player_stats.keys())
listOFratings = list(player_stats.values())
print ('ROSTER')
a_jersey = sorted (listOFjerseys)
for x in a_jersey:
print ("Jersey number: %d, Rating: %d" % (x,player_stats[x]))
player_stats = {}
entry_count = int(5)
for i in range(1,entry_count+1):
jersey_num = int(input("Enter player %d's jersey number:n" % i))
p_rating = int(input("Enter player %d's rating:nn" % i))
player_stats [jersey_num] = (p_rating)
listOFjerseys = list(player_stats.keys())
listOFratings = list(player_stats.values())
print ('ROSTER')
a_jersey = sorted (listOFjerseys)
for x in a_jersey:
print ("Jersey number: %d, Rating: %d" % (x,player_stats[x]))
choice = "" #I think this line is unused/unnecessary
print ('nMENU')
print ('a - Add player')
print ('d - Remove player')
print ('u - Update player rating')
print ('r - Output players above a rating')
print ('o - Output roster')
print ('q - Quit')
action_in = input('nChoose an option:n')
while action_in is True and action_in != 'q':
if action_in == 'a':
#Add player
jersey_num = int(input("nEnter a new player's jerseynumber:n"))
p_rating = int(input("Enter the player's rating:n"))
player_stats [jersey_num] = (p_rating)
output_roster()
print_menu()
elif action_in == 'd':
#Delete player
player = int(input("nEnter a jersey number:n"))
del player_stats[player]
output_roster()
print_menu()
elif action_in == 'u':
#Update rating
jersey_num = int(input("nEnter a jersey number:n"))
n_rating = int(input("Enter a new rating for player:n"))
player_stats [jersey_num] = (n_rating)
output_roster()
print_menu()
elif action_in == 'r':
#output > rating
rankVal = int(input("nEnter a rating:n"))
print ('ABOVE %dn' % rankVal)
for m, n in player_stats.values():
if n > rankVal:
print ('Jersey number: %d, Rating: %dn' % (m,n))
print_menu()
elif action_in == 'o':
#Output roster
output_roster()
print_menu()
if action_in == 'q':
#quit
raise SystemExit()
enter image description here
python function menu
|
show 1 more comment
EDIT REQUESTED:
I created two instances of the menu, one in a function and one outside the function because the initial test prompts the user to enter 5 jersey nums and the player rank, then expects a roster to be printed, then expects the user menu to prompt changes to the roster.
"Updating dictionary" I meant the roster is created in a dict{} and then the options of the user menu allow for editing the initial dict and then printing a new roster with the changes.
INITIAL POST:
I am having trouble with this code (class assignment, hw not test). The goal is a menu that allows the user to add and delete players from a roster, update their player rating, pull a list of the top x ratings, or simply print a roster. The assignment requires that the initial user input is 5 jersey numbers and their ratings, print a roster, then offer the user menu. I have solved the first 4 tasks. PROBLEM: when accessing menu items to add, delete, update, and rank the first roster that follows the initial 5 entries is being read as the answer instead of the roster that prints to the screen after changes are made. I can't figure out how to set it up so the roster after the initial setup is optional.
I'm hoping you will see an obvious error in the code that I'm missing. (The indentation looks a little funky to format for pasting in here. I have no indentation errors per the system.)
def print_menu():
print ('nMENU')
print ('a - Add player')
print ('d - Remove player')
print ('u - Update player rating')
print ('r - Output players above a rating')
print ('o - Output roster')
print ('q - Quit')
action_in = input('nChoose an option:n')
def output_roster():
listOFjerseys = list(player_stats.keys())
listOFratings = list(player_stats.values())
print ('ROSTER')
a_jersey = sorted (listOFjerseys)
for x in a_jersey:
print ("Jersey number: %d, Rating: %d" % (x,player_stats[x]))
player_stats = {}
entry_count = int(5)
for i in range(1,entry_count+1):
jersey_num = int(input("Enter player %d's jersey number:n" % i))
p_rating = int(input("Enter player %d's rating:nn" % i))
player_stats [jersey_num] = (p_rating)
listOFjerseys = list(player_stats.keys())
listOFratings = list(player_stats.values())
print ('ROSTER')
a_jersey = sorted (listOFjerseys)
for x in a_jersey:
print ("Jersey number: %d, Rating: %d" % (x,player_stats[x]))
choice = "" #I think this line is unused/unnecessary
print ('nMENU')
print ('a - Add player')
print ('d - Remove player')
print ('u - Update player rating')
print ('r - Output players above a rating')
print ('o - Output roster')
print ('q - Quit')
action_in = input('nChoose an option:n')
while action_in is True and action_in != 'q':
if action_in == 'a':
#Add player
jersey_num = int(input("nEnter a new player's jerseynumber:n"))
p_rating = int(input("Enter the player's rating:n"))
player_stats [jersey_num] = (p_rating)
output_roster()
print_menu()
elif action_in == 'd':
#Delete player
player = int(input("nEnter a jersey number:n"))
del player_stats[player]
output_roster()
print_menu()
elif action_in == 'u':
#Update rating
jersey_num = int(input("nEnter a jersey number:n"))
n_rating = int(input("Enter a new rating for player:n"))
player_stats [jersey_num] = (n_rating)
output_roster()
print_menu()
elif action_in == 'r':
#output > rating
rankVal = int(input("nEnter a rating:n"))
print ('ABOVE %dn' % rankVal)
for m, n in player_stats.values():
if n > rankVal:
print ('Jersey number: %d, Rating: %dn' % (m,n))
print_menu()
elif action_in == 'o':
#Output roster
output_roster()
print_menu()
if action_in == 'q':
#quit
raise SystemExit()
enter image description here
python function menu
1
Your first two functions have indention errors. Edit your Question and explain why do you haveMENU
two times and what do you mean with "updating dictionary"?
– stovfl
Nov 25 '18 at 18:53
Sorry, the indention errors aren't in the code. It's something with the format required for getting the code to show here. The print_menu is there as code for the initial process and then again as a function to call after each menu option is completed, to allow the user to make another choice.
– tsfarber
Nov 25 '18 at 19:04
As it stands, it's not clear which code belongs todef output_roster()
. You do calloutput_roster()
, if inside ofdef output_roster()
it's recursive which proably is not what you want.while action_in is True...
is alwaysFalse
, explain why you use this.
– stovfl
Nov 25 '18 at 20:23
I played with the format above so you can see the indents more clearly and tried to resolve the spacing so you can identify the statements contained in the output roster () function. I do not understand the statement by stovfl that "while action_in is True is always False" the intent for the while loop is to move through the user's choices in the menu that are not 'q' to execute the proper statements or call the proper function. Outside the loop is what to do if action_in is 'q' and I had a print output prompting the user to choose again if False. I dropped those 2 lines while troubleshooting.
– tsfarber
Nov 25 '18 at 23:24
You still have idention errors! Put thisprint(bool(action_in is True))
right afteraction_in = input(...
and see if you ever getTrue
. Read 6.10.3. Identity comparisons. Reconsider your approach: "the intent for the while loop is to move through the user's choices in the menu". If thewhile
condition ever getsTrue
you will end up with a infinit loop.
– stovfl
Nov 26 '18 at 8:14
|
show 1 more comment
EDIT REQUESTED:
I created two instances of the menu, one in a function and one outside the function because the initial test prompts the user to enter 5 jersey nums and the player rank, then expects a roster to be printed, then expects the user menu to prompt changes to the roster.
"Updating dictionary" I meant the roster is created in a dict{} and then the options of the user menu allow for editing the initial dict and then printing a new roster with the changes.
INITIAL POST:
I am having trouble with this code (class assignment, hw not test). The goal is a menu that allows the user to add and delete players from a roster, update their player rating, pull a list of the top x ratings, or simply print a roster. The assignment requires that the initial user input is 5 jersey numbers and their ratings, print a roster, then offer the user menu. I have solved the first 4 tasks. PROBLEM: when accessing menu items to add, delete, update, and rank the first roster that follows the initial 5 entries is being read as the answer instead of the roster that prints to the screen after changes are made. I can't figure out how to set it up so the roster after the initial setup is optional.
I'm hoping you will see an obvious error in the code that I'm missing. (The indentation looks a little funky to format for pasting in here. I have no indentation errors per the system.)
def print_menu():
print ('nMENU')
print ('a - Add player')
print ('d - Remove player')
print ('u - Update player rating')
print ('r - Output players above a rating')
print ('o - Output roster')
print ('q - Quit')
action_in = input('nChoose an option:n')
def output_roster():
listOFjerseys = list(player_stats.keys())
listOFratings = list(player_stats.values())
print ('ROSTER')
a_jersey = sorted (listOFjerseys)
for x in a_jersey:
print ("Jersey number: %d, Rating: %d" % (x,player_stats[x]))
player_stats = {}
entry_count = int(5)
for i in range(1,entry_count+1):
jersey_num = int(input("Enter player %d's jersey number:n" % i))
p_rating = int(input("Enter player %d's rating:nn" % i))
player_stats [jersey_num] = (p_rating)
listOFjerseys = list(player_stats.keys())
listOFratings = list(player_stats.values())
print ('ROSTER')
a_jersey = sorted (listOFjerseys)
for x in a_jersey:
print ("Jersey number: %d, Rating: %d" % (x,player_stats[x]))
choice = "" #I think this line is unused/unnecessary
print ('nMENU')
print ('a - Add player')
print ('d - Remove player')
print ('u - Update player rating')
print ('r - Output players above a rating')
print ('o - Output roster')
print ('q - Quit')
action_in = input('nChoose an option:n')
while action_in is True and action_in != 'q':
if action_in == 'a':
#Add player
jersey_num = int(input("nEnter a new player's jerseynumber:n"))
p_rating = int(input("Enter the player's rating:n"))
player_stats [jersey_num] = (p_rating)
output_roster()
print_menu()
elif action_in == 'd':
#Delete player
player = int(input("nEnter a jersey number:n"))
del player_stats[player]
output_roster()
print_menu()
elif action_in == 'u':
#Update rating
jersey_num = int(input("nEnter a jersey number:n"))
n_rating = int(input("Enter a new rating for player:n"))
player_stats [jersey_num] = (n_rating)
output_roster()
print_menu()
elif action_in == 'r':
#output > rating
rankVal = int(input("nEnter a rating:n"))
print ('ABOVE %dn' % rankVal)
for m, n in player_stats.values():
if n > rankVal:
print ('Jersey number: %d, Rating: %dn' % (m,n))
print_menu()
elif action_in == 'o':
#Output roster
output_roster()
print_menu()
if action_in == 'q':
#quit
raise SystemExit()
enter image description here
python function menu
EDIT REQUESTED:
I created two instances of the menu, one in a function and one outside the function because the initial test prompts the user to enter 5 jersey nums and the player rank, then expects a roster to be printed, then expects the user menu to prompt changes to the roster.
"Updating dictionary" I meant the roster is created in a dict{} and then the options of the user menu allow for editing the initial dict and then printing a new roster with the changes.
INITIAL POST:
I am having trouble with this code (class assignment, hw not test). The goal is a menu that allows the user to add and delete players from a roster, update their player rating, pull a list of the top x ratings, or simply print a roster. The assignment requires that the initial user input is 5 jersey numbers and their ratings, print a roster, then offer the user menu. I have solved the first 4 tasks. PROBLEM: when accessing menu items to add, delete, update, and rank the first roster that follows the initial 5 entries is being read as the answer instead of the roster that prints to the screen after changes are made. I can't figure out how to set it up so the roster after the initial setup is optional.
I'm hoping you will see an obvious error in the code that I'm missing. (The indentation looks a little funky to format for pasting in here. I have no indentation errors per the system.)
def print_menu():
print ('nMENU')
print ('a - Add player')
print ('d - Remove player')
print ('u - Update player rating')
print ('r - Output players above a rating')
print ('o - Output roster')
print ('q - Quit')
action_in = input('nChoose an option:n')
def output_roster():
listOFjerseys = list(player_stats.keys())
listOFratings = list(player_stats.values())
print ('ROSTER')
a_jersey = sorted (listOFjerseys)
for x in a_jersey:
print ("Jersey number: %d, Rating: %d" % (x,player_stats[x]))
player_stats = {}
entry_count = int(5)
for i in range(1,entry_count+1):
jersey_num = int(input("Enter player %d's jersey number:n" % i))
p_rating = int(input("Enter player %d's rating:nn" % i))
player_stats [jersey_num] = (p_rating)
listOFjerseys = list(player_stats.keys())
listOFratings = list(player_stats.values())
print ('ROSTER')
a_jersey = sorted (listOFjerseys)
for x in a_jersey:
print ("Jersey number: %d, Rating: %d" % (x,player_stats[x]))
choice = "" #I think this line is unused/unnecessary
print ('nMENU')
print ('a - Add player')
print ('d - Remove player')
print ('u - Update player rating')
print ('r - Output players above a rating')
print ('o - Output roster')
print ('q - Quit')
action_in = input('nChoose an option:n')
while action_in is True and action_in != 'q':
if action_in == 'a':
#Add player
jersey_num = int(input("nEnter a new player's jerseynumber:n"))
p_rating = int(input("Enter the player's rating:n"))
player_stats [jersey_num] = (p_rating)
output_roster()
print_menu()
elif action_in == 'd':
#Delete player
player = int(input("nEnter a jersey number:n"))
del player_stats[player]
output_roster()
print_menu()
elif action_in == 'u':
#Update rating
jersey_num = int(input("nEnter a jersey number:n"))
n_rating = int(input("Enter a new rating for player:n"))
player_stats [jersey_num] = (n_rating)
output_roster()
print_menu()
elif action_in == 'r':
#output > rating
rankVal = int(input("nEnter a rating:n"))
print ('ABOVE %dn' % rankVal)
for m, n in player_stats.values():
if n > rankVal:
print ('Jersey number: %d, Rating: %dn' % (m,n))
print_menu()
elif action_in == 'o':
#Output roster
output_roster()
print_menu()
if action_in == 'q':
#quit
raise SystemExit()
enter image description here
python function menu
python function menu
edited Nov 25 '18 at 23:18
tsfarber
asked Nov 25 '18 at 18:43
tsfarbertsfarber
12
12
1
Your first two functions have indention errors. Edit your Question and explain why do you haveMENU
two times and what do you mean with "updating dictionary"?
– stovfl
Nov 25 '18 at 18:53
Sorry, the indention errors aren't in the code. It's something with the format required for getting the code to show here. The print_menu is there as code for the initial process and then again as a function to call after each menu option is completed, to allow the user to make another choice.
– tsfarber
Nov 25 '18 at 19:04
As it stands, it's not clear which code belongs todef output_roster()
. You do calloutput_roster()
, if inside ofdef output_roster()
it's recursive which proably is not what you want.while action_in is True...
is alwaysFalse
, explain why you use this.
– stovfl
Nov 25 '18 at 20:23
I played with the format above so you can see the indents more clearly and tried to resolve the spacing so you can identify the statements contained in the output roster () function. I do not understand the statement by stovfl that "while action_in is True is always False" the intent for the while loop is to move through the user's choices in the menu that are not 'q' to execute the proper statements or call the proper function. Outside the loop is what to do if action_in is 'q' and I had a print output prompting the user to choose again if False. I dropped those 2 lines while troubleshooting.
– tsfarber
Nov 25 '18 at 23:24
You still have idention errors! Put thisprint(bool(action_in is True))
right afteraction_in = input(...
and see if you ever getTrue
. Read 6.10.3. Identity comparisons. Reconsider your approach: "the intent for the while loop is to move through the user's choices in the menu". If thewhile
condition ever getsTrue
you will end up with a infinit loop.
– stovfl
Nov 26 '18 at 8:14
|
show 1 more comment
1
Your first two functions have indention errors. Edit your Question and explain why do you haveMENU
two times and what do you mean with "updating dictionary"?
– stovfl
Nov 25 '18 at 18:53
Sorry, the indention errors aren't in the code. It's something with the format required for getting the code to show here. The print_menu is there as code for the initial process and then again as a function to call after each menu option is completed, to allow the user to make another choice.
– tsfarber
Nov 25 '18 at 19:04
As it stands, it's not clear which code belongs todef output_roster()
. You do calloutput_roster()
, if inside ofdef output_roster()
it's recursive which proably is not what you want.while action_in is True...
is alwaysFalse
, explain why you use this.
– stovfl
Nov 25 '18 at 20:23
I played with the format above so you can see the indents more clearly and tried to resolve the spacing so you can identify the statements contained in the output roster () function. I do not understand the statement by stovfl that "while action_in is True is always False" the intent for the while loop is to move through the user's choices in the menu that are not 'q' to execute the proper statements or call the proper function. Outside the loop is what to do if action_in is 'q' and I had a print output prompting the user to choose again if False. I dropped those 2 lines while troubleshooting.
– tsfarber
Nov 25 '18 at 23:24
You still have idention errors! Put thisprint(bool(action_in is True))
right afteraction_in = input(...
and see if you ever getTrue
. Read 6.10.3. Identity comparisons. Reconsider your approach: "the intent for the while loop is to move through the user's choices in the menu". If thewhile
condition ever getsTrue
you will end up with a infinit loop.
– stovfl
Nov 26 '18 at 8:14
1
1
Your first two functions have indention errors. Edit your Question and explain why do you have
MENU
two times and what do you mean with "updating dictionary"?– stovfl
Nov 25 '18 at 18:53
Your first two functions have indention errors. Edit your Question and explain why do you have
MENU
two times and what do you mean with "updating dictionary"?– stovfl
Nov 25 '18 at 18:53
Sorry, the indention errors aren't in the code. It's something with the format required for getting the code to show here. The print_menu is there as code for the initial process and then again as a function to call after each menu option is completed, to allow the user to make another choice.
– tsfarber
Nov 25 '18 at 19:04
Sorry, the indention errors aren't in the code. It's something with the format required for getting the code to show here. The print_menu is there as code for the initial process and then again as a function to call after each menu option is completed, to allow the user to make another choice.
– tsfarber
Nov 25 '18 at 19:04
As it stands, it's not clear which code belongs to
def output_roster()
. You do call output_roster()
, if inside of def output_roster()
it's recursive which proably is not what you want. while action_in is True...
is always False
, explain why you use this.– stovfl
Nov 25 '18 at 20:23
As it stands, it's not clear which code belongs to
def output_roster()
. You do call output_roster()
, if inside of def output_roster()
it's recursive which proably is not what you want. while action_in is True...
is always False
, explain why you use this.– stovfl
Nov 25 '18 at 20:23
I played with the format above so you can see the indents more clearly and tried to resolve the spacing so you can identify the statements contained in the output roster () function. I do not understand the statement by stovfl that "while action_in is True is always False" the intent for the while loop is to move through the user's choices in the menu that are not 'q' to execute the proper statements or call the proper function. Outside the loop is what to do if action_in is 'q' and I had a print output prompting the user to choose again if False. I dropped those 2 lines while troubleshooting.
– tsfarber
Nov 25 '18 at 23:24
I played with the format above so you can see the indents more clearly and tried to resolve the spacing so you can identify the statements contained in the output roster () function. I do not understand the statement by stovfl that "while action_in is True is always False" the intent for the while loop is to move through the user's choices in the menu that are not 'q' to execute the proper statements or call the proper function. Outside the loop is what to do if action_in is 'q' and I had a print output prompting the user to choose again if False. I dropped those 2 lines while troubleshooting.
– tsfarber
Nov 25 '18 at 23:24
You still have idention errors! Put this
print(bool(action_in is True))
right after action_in = input(...
and see if you ever get True
. Read 6.10.3. Identity comparisons. Reconsider your approach: "the intent for the while loop is to move through the user's choices in the menu". If the while
condition ever gets True
you will end up with a infinit loop.– stovfl
Nov 26 '18 at 8:14
You still have idention errors! Put this
print(bool(action_in is True))
right after action_in = input(...
and see if you ever get True
. Read 6.10.3. Identity comparisons. Reconsider your approach: "the intent for the while loop is to move through the user's choices in the menu". If the while
condition ever gets True
you will end up with a infinit loop.– stovfl
Nov 26 '18 at 8:14
|
show 1 more comment
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53470719%2fpython-3-project-user-menu-for-updating-dictionary%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53470719%2fpython-3-project-user-menu-for-updating-dictionary%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Your first two functions have indention errors. Edit your Question and explain why do you have
MENU
two times and what do you mean with "updating dictionary"?– stovfl
Nov 25 '18 at 18:53
Sorry, the indention errors aren't in the code. It's something with the format required for getting the code to show here. The print_menu is there as code for the initial process and then again as a function to call after each menu option is completed, to allow the user to make another choice.
– tsfarber
Nov 25 '18 at 19:04
As it stands, it's not clear which code belongs to
def output_roster()
. You do calloutput_roster()
, if inside ofdef output_roster()
it's recursive which proably is not what you want.while action_in is True...
is alwaysFalse
, explain why you use this.– stovfl
Nov 25 '18 at 20:23
I played with the format above so you can see the indents more clearly and tried to resolve the spacing so you can identify the statements contained in the output roster () function. I do not understand the statement by stovfl that "while action_in is True is always False" the intent for the while loop is to move through the user's choices in the menu that are not 'q' to execute the proper statements or call the proper function. Outside the loop is what to do if action_in is 'q' and I had a print output prompting the user to choose again if False. I dropped those 2 lines while troubleshooting.
– tsfarber
Nov 25 '18 at 23:24
You still have idention errors! Put this
print(bool(action_in is True))
right afteraction_in = input(...
and see if you ever getTrue
. Read 6.10.3. Identity comparisons. Reconsider your approach: "the intent for the while loop is to move through the user's choices in the menu". If thewhile
condition ever getsTrue
you will end up with a infinit loop.– stovfl
Nov 26 '18 at 8:14