-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
31 lines (27 loc) · 1017 Bytes
/
main.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
while True:
user_action = input('Type add, show, edit, complete or exit: ')
user_action = user_action.strip()
match user_action:
case 'add':
todo = input('Enter a todo') + '\n'
file = open('todos.txt', 'r')
todos = file.readlines()
todos.append(todo)
file = open('todos.txt', 'w')
file.writelines(todos)
case 'show':
file = open('todos.txt', 'r')
todos = file.readlines()
for index, item in enumerate(todos):
item = item.capitalize()
print(f'{index + 1} -{item}')
case 'edit':
existing_todo_index = int(input('Number of todo to edit: '))
edited_todo = input('Edit your todo now: ')
todos[existing_todo_index-1] = edited_todo
case 'complete':
number = int(input('Number of todo to complete: '))
todos.pop(number - 1)
case 'exit':
break
print('Bye!')