-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctionexample2.py
More file actions
32 lines (26 loc) · 821 Bytes
/
Copy pathfunctionexample2.py
File metadata and controls
32 lines (26 loc) · 821 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
# from functions import get_list_from_file, write_list_to_file
import functions
while True:
userText = input("Always Type add, show or exit.").strip()
li = functions.get_list_from_file()
if "add" in userText:
y = userText[4:]
li.append(y + "\n")
functions.write_list_to_file(li)
elif "show" in userText:
print(li)
for i, j in enumerate(li):
print(i + 1, ":", j.strip("\n"))
# print(f"New Format string: {i+1}={j}")
# print(list(enumerate(li)))
elif "edit" in userText:
i = int(userText[5:])
v = input("Enter Element Text: ")
li[i - 1] = v + "\n"
print(li)
functions.write_list_to_file(li)
elif "exit" in userText:
break
else:
print("Command not valid.")
print("Bye")