How do i write a python code so that my list of numbers can be updated within an elif cause?
I start off with an empty an empty list then from there i have to ask the user how many new scores they want to add to the list then add those numbers to the list.Then i have to go back to the menu system and ask the user to press 3 if they want the average of those number in the list. here my code below the problem im having is that the scores are being updated in the elif clause but once i get out the clause the list goes back to being empty. please help!
while 1: print("0 - clear out scores") print("1 - input more scores") print("2 - display all scores") print("3 - get average scores") option = int(input("\n Please seclet an opition: ")) scores = def clearScores(): scores =  def addScores(): x=1 while x < 2 : numOfScores = int(input("How many new scores would you like to add :")) if numOfScores < 0: print("Please enter a postivite integer for the number of scores you would like to add.") else: index = 0 while index < numOfScores: new_num = eval(input("Enter score: ")) scores.append(new_num) index += 1 print(scores) x += 2 return scores if option == 0: clearScores() print("The scores has been cleared") elif option == 1: scores.append(addScores()) elif option == 2: printScores() elif option == 3: averageScores() else: print("goodbye") replay = input("\nDo You Want To Continue? Y/N: ") replay = replay.lower() if (replay == "yes") or (replay == "y"): pass else: print("\nGoodbye!")
Edited 4 Years Ago by anishxx323