-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path45_Challenge-TodoListv2.py
129 lines (110 loc) · 2.88 KB
/
45_Challenge-TodoListv2.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
123
124
125
126
127
128
129
# Day 45 on Replit: "Challenge: Ta Daaaa! It's A To Do"
import os, time
myList = []
print("ToDo List Manager")
def showMenu():
print("What do you want to do?\n1. View\n2. Add\n3. Remove\n4. Edit")
option = int(input("> "))
return option
def clearConsole(sec):
time.sleep(sec)
os.system("clear")
def prettyPrint():
print()
for row in myList:
for item in row:
print(f"{item: ^15}", end = " | ")
print()
print()
def printPerPriority(option):
print()
for row in myList:
if option in row:
for item in row:
print(f"{item: ^15}", end = " | ")
print()
def view():
print("VIEW")
print()
option = int(input("1. View all\n2. View Prority\n>"))
if option == 1:
prettyPrint()
elif option == 2:
print()
print("Choose a priority")
priority = int(input("1. High\n2. Medium\n3. Low\n>"))
if priority == 1:
printPerPriority("High")
elif priority == 2:
printPerPriority("Medium")
elif priority == 3:
printPerPriority("Low")
else:
print("Option not found!")
def add():
print("ADD")
print()
task = input("What is it? ").strip().capitalize()
date = input("When is it due by? ").strip().capitalize()
priority = input("What is the priority? (High | Medium | Low) ").strip().capitalize()
row = [task, date, priority]
myList.append(row)
print("Task added")
def remove():
item = input("What do you want to remove? ").strip().capitalize()
for row in myList:
if item in row:
print()
choice = input(f"Are you sure you want to remove {item}? ").strip().lower()
if choice == "yes":
myList.remove(row)
print()
print("Item removed")
elif item == "everything" or item == "Everything":
myList.clear()
print()
print("ToDo erased")
else:
print()
print(f"{item} doesn´t exist")
def edit():
print("EDIT")
item = input("What do you want to edit? ").strip().capitalize()
for row in myList:
if item in row:
print()
task = input("What is it? ").strip().capitalize()
date = input("When is it due by? ").strip().capitalize()
priority = input("What is the priority? (High | Medium | Low")
print()
choice = input("You´re about to edit your ToDo. Continue? (y/n)").strip().lower()
if choice[0] == "y" :
newItem = [task, date, priority]
print()
myList.remove(row)
myList.append(newItem)
print("Item edited")
else:
print()
print("Operation canceled")
else:
print("Item dont found!")
while True:
clearConsole(1)
choice = showMenu()
if choice == 1:
clearConsole(0.5)
view()
clearConsole(5)
elif choice == 2:
clearConsole(0.5)
add()
elif choice == 3:
clearConsole(0.5)
remove()
elif choice == 4:
clearConsole(0.5)
edit()
else:
print("I don´t get it. Bye")
break