-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbetter_buy_computer.py
32 lines (32 loc) · 1.17 KB
/
better_buy_computer.py
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
available_parts = ["Computer",
"Monitor",
"Keyboard",
"Mouse",
"Mouse mat",
"Microphone",
"DVD drive",
"Gaming Chair"
]
valid_choices = [str(i) for i in range(1, len(available_parts) + 1)]
print(valid_choices)
current_basket = "-"
computer_parts = [] # empty list
add_item = []
while current_basket != '0':
if current_basket in valid_choices:
print("Adding part no. {}".format(current_basket))
index = int(current_basket) - 1
chosen_part = available_parts[index]
computer_parts.append(chosen_part)
elif current_basket == '515':
add_item = input("Please add new item to the shop:\n")
available_parts.append(add_item)
valid_choices = [str(i) for i in range(1, len(available_parts) + 1)]
print(valid_choices)
else:
print("Add options from the list below:")
for number, part in enumerate(available_parts):
print("{}: {}".format(number + 1, part))
current_basket = input()
print(valid_choices)
print(computer_parts)