-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhigh_scores.129.py
More file actions
55 lines (44 loc) · 976 Bytes
/
high_scores.129.py
File metadata and controls
55 lines (44 loc) · 976 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#High Scores
#Demonstrates list methods
# pg 129
scores = []
choice = None
while choice != "0":
print(
"""
High Scores
0 - Exit
1 - Show Scores
2 - Add a score
3 - Delete a score
4 - Sort scores
***
"""
)
choice = input("Choice: ")
print()
#exit
if choice == "0":
print("END")
#list high-scores table
elif choice == "1":
print("High Scores")
for score in scores:
print(score)
#add a score
elif choice == "2":
score = int(input("What score did you get?: "))
scores.append(score)
#remove a score
elif choice == "3":
score = int(input("Remove which score?: "))
if score in scores:
scores.remove(score)
else:
print(score, " can't be found in the list.")
#sort scores
elif choice == "4":
scores.sort(reverse=True)
#default
else:
print("Invalid choice.")