I am having trouble with getting the return function to work. I says : nam \'cho
ID: 3807533 • Letter: I
Question
I am having trouble with getting the return function to work. I says : nam 'choice' is not defined
def main():
intro()
print_menu()
get_user_choice()
process_choice(choice)
def intro():
print('Description of program')
print('===========================')
def print_menu():
print("1. Add players' record " +
"2. Display players' record " +
"3. Modify a player's record " +
"4. Remove a player's record " +
"5. Stop " +
"===========================")
def get_user_choice():
choice = int(input("Enter your choice: "))
return choice
def process_choice(choice):
if choice == 1:
print('you picked 1')
elif choice == 2:
print('you picked 2')
elif choice == 3:
print('you picked 3')
Explanation / Answer
def main():
intro()
print_menu()
choice=get_user_choice()
process_choice(choice)
def intro():
print('Description of program')
print('===========================')
def print_menu():
print("1. Add players' record " +
"2. Display players' record " +
"3. Modify a player's record " +
"4. Remove a player's record " +
"5. Stop " +
"===========================")
def get_user_choice():
choice = int(input("Enter your choice: "))
return choice
def process_choice(choice):
if choice == 1:
print('you picked 1')
elif choice == 2:
print('you picked 2')
elif choice == 3:
print('you picked 3')
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.