-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathto-do-list(save-to-file).py
81 lines (74 loc) · 1.68 KB
/
to-do-list(save-to-file).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
# | Name | Date | Priority
import os, time
todo = []
def add():
time.sleep(1)
os.system("clear")
name = input("Name > ")
date = input("Due Date > ")
priority = input("Priority > ").capitalize()
row = [name, date, priority]
todo.append(row)
print("Added")
def view():
time.sleep(1)
os.system("clear")
options = input("1: All\n2: By Priority\n> ")
if options=="1":
for row in todo:
for item in row:
print(item, end=" | ")
print()
print()
else:
priority = input("What priority? > ").capitalize()
for row in todo:
if priority in row:
for item in row:
print(item, end=" | ")
print()
print()
time.sleep(1)
def edit():
time.sleep(1)
os.system("clear")
find = input("Name of todo to edit > ")
found = False
for row in todo:
if find in row:
found = True
if not found:
print("Couldn't find that")
return
for row in todo:
if find in row:
todo.remove(row)
name = input("Name > ")
date = input("Due Date > ")
priority = input("Priority > ").capitalize()
row = [name, date, priority]
todo.append(row)
print("Added")
def remove():
time.sleep(1)
os.system("clear")
find = input("Name of todo to remove > ")
for row in todo:
if find in row:
todo.remove(row)
while True:
menu = input("1: Add\n2: View\n3: Edit\n4: Remove\n> ")
if menu == "1":
add()
elif menu == "2":
view()
elif menu == "3":
edit()
else:
remove()
time.sleep(1)
os.system("clear")
###### Salvataggio su file ####
f = open("to.do.list.txt", "w")
f.write(str(todo))
f.close()