-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame_listv2.py
More file actions
45 lines (40 loc) · 1.35 KB
/
game_listv2.py
File metadata and controls
45 lines (40 loc) · 1.35 KB
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
game_list = []
while True:
option = int(input("""
1 - Add a game,
2 - remove a game,
3 - insert a game.
Enter a choice 1,2, or 3
"""))
if option == 1:
print("this option allows you to add a game to your list")
print(game_list)
game = input("what game would you like to add to your list: ")
game_list.append(game)
print(game_list)
elif option == 2:
print("this option will allow you to remove a game from your list")
print(game_list)
while True:
game = input("what game would you like to remove from your list: ")
if game in game_list:
game_list.remove(game)
print(game_list)
break
else:
print("that game is not on your list")
elif option == 3:
print("this option allows you to insert a game at a given position")
game = input("what game would you like to insert in your list: ")
while True:
pos = int(input("at what position would you like to insert this game: "))
pos -= 1
if pos < len(game_list):
game_list.insert(pos, game)
print(game_list)
break
else:
print("invalid position")
if option == 4:
input("press enter to exit")
break