-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshopping_list_3.py
40 lines (35 loc) · 1.08 KB
/
shopping_list_3.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
33
34
35
36
37
38
39
40
shopping_list = []
def show_help():
print("Separate each item with a comma.")
print("Type DONE to quit, SHOW to see the current list, and HELP.")
def show_list():
count = 1
for item in shopping_list:
print("{}: {}".format(count, item))
count += 1
print("Give me a list of things.")
show_help()
while True:
new_stuff = input("> ")
if new_stuff == "DONE":
print("Here's your list:")
show_list()
break
elif new_stuff == "HELP":
show_help()
continue
elif new_stuff == "SHOW":
show_list()
continue
else:
new_list = new_stuff.split(",")
index = input("Add to a certain spot? Press enter for the end of the list. Or, give me a number. Current {} items in the list. ".format(len(shopping_list)))
if index:
spot = int(index) - 1
for item in new_list:
shopping_list.insert(spot, item.strip())
spot += 1
else:
for item in new_list:
shopping_list.append(item.strip())
continue