-
Notifications
You must be signed in to change notification settings - Fork 0
/
testing.txt
47 lines (31 loc) · 1.02 KB
/
testing.txt
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
def updating (write):
with open("harry.txt","a") as f:
f.write(f"{write} \n")
def delete (word):
lst_old = []
lst_new = []
with open ("harry.txt","r+") as f:
l = f.readlines()
for i in l:
lst_old.append(i)
print(lst_old)
m = len(lst_old)
print(lst_old.index(f"{word} \n"))
for i in lst_old:
if(f"{word} \n" in lst_old):
lst_old.remove(f"{word} \n")
print("All Working")
# print(f"new list : {lst_old}")
for letter in lst_old:
lst_new.append(letter)
print(lst_new)
with open("harry.txt","wt") as f:
for letter in lst_new:
f.write(letter)
choice = input("Enter your choice : ")
if(choice == "up"):
write = input("Enter the Word you want to update : ")
updating(write)
elif(choice == "del"):
word = input("Enter the Word you want to remove : ")
delete(word)