I am doing a program for a command line interface and am having a issue getting a error when trying to use reverse and sort.
Here is my program: https://repl.it/@Michael_Nicol/hwk4py
I also pasted it below.
May seem like a lot, but the only error and issue I am having is with line 25. I tried both reverse()
and reversed()
and nothing is working. I keep getting this error despite me being correct according to read documentation.
menu = '''
Scoring Engine V2.0.1
1. Press 1 to exit
2. Press 2 to display scores from highest to lowest
3. Press 3 to add a score to the list
4. Press 4 to just show highest and lowest scores
'''
print(menu)
done = False
scores = [85.3, 85.2, 21.99] # Starting scores
while not done:
scores.sort()
scores.reversed()
selection = input("Choice: ")
if selection == "1":
done = True
print("Program Exited")
break;
elif selection == "2":
print()
for i in scores:
print("\t", i)
print()
elif selection == "3":
single_score = input("Input a score: ")
try:
single_score = float(single_score) # Check if input is a number
except:
"Error: Inputted value is not a number" # Errors if not number
else:
single_score = '{0:.{1}f}'.format(single_score, 2) # Cuts off to 100th place
scores.append(single_score) # Adds to score list
elif selection == "4":
print("Highest: ", scores[0])
print("Lowest: ", scores[len(scores)-1]) # Length of array - 1 for last item
else:
print("Error: Bad Choice") # Bad selection choice
print("-----------------------") # For formatting