-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuy_computer.py
More file actions
35 lines (32 loc) · 1.21 KB
/
Copy pathbuy_computer.py
File metadata and controls
35 lines (32 loc) · 1.21 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
available_parts = ["computer",
"monitor",
"keyboard",
"mouse",
"mouse-mat",
"hdmi cable",
"dvd drive"
]
# valid_choices = [str(i) for i in range(1, len(available_parts)+1)]
valid_choices = []
for i in range (1, len(available_parts)+1):
valid_choices.append(str(i))
print(valid_choices)
current_choice = "-"
computer_parts = [] # create an empty list
while current_choice != "0":
if current_choice in valid_choices:
index = int(current_choice) - 1
chosen_part = available_parts[index]
if chosen_part in computer_parts:
print("Removing {}".format(current_choice))
computer_parts.remove(chosen_part)
else:
computer_parts.append(chosen_part)
print("Adding {}".format(current_choice))
print("Your list now contais {}".format(computer_parts))
else:
print("Please add options from the list below: ")
for number, part in enumerate(available_parts):
print("{0}: {1}".format(number+1, part))
current_choice = input()
print(computer_parts)