-
Notifications
You must be signed in to change notification settings - Fork 0
/
replits100DaysOfPython_day35_theUltimateListMaker.py
122 lines (103 loc) · 3.21 KB
/
replits100DaysOfPython_day35_theUltimateListMaker.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import os #system()
import time #sleep()
# todo_list = []
todo_list = ["Create a list.", "Fill the list with dummy data.", "Wash the dishes.", "Eat.", "Feed the dogs.", "Finish today's challenge."]
def view():
if len(todo_list) == 0:
print("The list is empty!\n")
time.sleep(1)
else:
print("Printing the current todo list...\n")
time.sleep(1)
for task in range(0, len(todo_list)):
print(f"{task + 1:>2}: {todo_list[task]}")
time.sleep(.25)
print("\nEnd of the list.\n")
time.sleep(1)
print("Returning to the main menu...\n")
time.sleep(1)
def add():
task = input("What task would you like to add?\n>> ").strip().lower().capitalize()
print()
if task not in todo_list:
todo_list.append(task)
view()
elif task in todo_list:
print("Duplicate task!\n")
time.sleep(1)
print("Returning to the main menu...\n")
time.sleep(1)
else:
print("ERROR! Unable to add task.")
time.sleep(1)
print("Returning to the main menu...\n")
time.sleep(1)
def edit():
view()
original_task = input("Which task would you like to edit?\n>> ").strip().lower().capitalize()
print()
replacement_task = input("What task would you like instead?\n>> ").strip().lower().capitalize()
print()
if original_task in todo_list and replacement_task not in todo_list:
original_task_index = todo_list.index(original_task)
todo_list[original_task_index] = replacement_task
view()
else:
print("ERROR! Unable to edit task.\n\nReturning to the main menu...\n")
time.sleep(1)
print("Returning to the main menu...\n")
time.sleep(1)
def remove():
view()
task = input("What task would you like to remove?\n>> ").strip().lower().capitalize()
print()
if task in todo_list:
choice = input(f"Are you sure you want to remove '{task}'?\n>> ").strip().lower()
print()
if choice[0] == 'y':
todo_list.remove(task)
view()
elif task not in todo_list:
print("Missing task!\n")
time.sleep(1)
print("Returning to the main menu...\n")
time.sleep(1)
else:
print("ERROR! Unable to remove task.\n")
time.sleep(1)
print("Returning to the main menu...\n")
time.sleep(1)
def remove_all():
choice = input(f"Are you sure you want to clear the list?\n>> ").strip().lower()
print()
if choice[0] == 'y':
todo_list.clear()
view()
def print_main_menu():
print("ToDo List Manager\n")
time.sleep(1)
print("Do you want to view, add, remove, edit, or clear the todo list?")
time.sleep(1)
while True:
os.system("cls")
print_main_menu()
choice = input(">> ").strip().lower()
print()
if choice == "view":
view()
continue
elif choice == "add":
add()
continue
elif choice == "edit":
edit()
continue
elif choice == "remove":
remove()
continue
elif choice == "clear":
remove_all()
continue
else:
print("Exiting the program...")
exit()