-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtodolist
More file actions
38 lines (30 loc) · 812 Bytes
/
todolist
File metadata and controls
38 lines (30 loc) · 812 Bytes
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
def add():
while True:
task = input("Add a task (q for quit): ").lower()
if task == "q":
break
with open('task.txt', 'a') as f:
f.write(task + "\n")
def view():
with open('task.txt', 'r') as f:
for line in f.readlines():
data = line.rstrip()
print("Task:", data)
print()
def clear():
with open('task.txt', 'w') as f:
pass
print("All tasks have been cleared.")
while True:
ctask = input("What do you want (add, view, clear, q): ").lower()
if ctask == "add":
add()
elif ctask == "view":
view()
elif ctask == "clear":
clear()
elif ctask == "q":
print("Goodbye!")
break
else:
print("Invalid option, please choose again.")