forked from AmI-2018/python-lab2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEx2.py
More file actions
53 lines (43 loc) · 1002 Bytes
/
Ex2.py
File metadata and controls
53 lines (43 loc) · 1002 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from sys import argv
task = []
exit_status = 0
def insert(st):
task.append(st)
def save(n,filename):
inpt=open(filename, "w")
for x in n:
inpt.write(x+"\n")
inpt.close()
filename = argv[1]
inpt = open(filename)
for line in inpt:
insert(line.strip())
inpt.close()
while exit_status == 0:
print("To-do Manager:")
print("1. Insert new task")
print("2. Remove task")
print("3. Show all tasks")
print("4. Exit")
choice = int(input())
if choice == 1:
print("Insert name: ")
name = input()
insert(name)
elif choice == 2:
print("Insert name: ")
name = input()
if name not in task:
print("Not found")
else:
task.remove(name)
elif choice == 3:
a = 1
for x in sorted(task):
print(str(a) + ")", x)
a += 1
elif choice == 4:
exit_status = 1
save(task,filename)
else:
print("Wrong number!")