-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwhilematchfor.py
More file actions
36 lines (31 loc) · 995 Bytes
/
Copy pathwhilematchfor.py
File metadata and controls
36 lines (31 loc) · 995 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
while True:
userText = input("Always Type add, show or exit.").strip()
file = open("files/todo.txt", "r")
li = file.readlines()
file.close()
match userText:
case "add":
y = input("Enter any value: ")
li.append(y + "\n")
file = open("files/todo.txt", "w")
file.writelines(li)
file.close()
case "show":
print(li)
for i, j in enumerate(li):
print(i+1, ":", j)
# print(f"New Format string: {i+1}={j}")
# print(list(enumerate(li)))
case "edit":
i = int(input("Enter number to edit element"))
v = input("Enter Element Text: ")
li[i-1] = v
print(li)
file = open("files/todo.txt", "w")
file.writelines(li)
file.close()
case "exit":
break
case whatever:
print("Enter only specified values")
print("Bye")