you could loop through the lines until you find it with readlines
DELITEM():
kw = Dele.get()
with open('notify.txt', 'r') as f:
if kw in f.read:
lines = f.readlines()
for i in range(len(lines)):
if kw in lines[i]:
print("The line is",i)
break
To delete the line from the text file, on way would be to delete the line in the list then write the lines back onto the file. So something like this
del lines[i]
then have another with where you write
with open('notify.txt', 'w') as f:
for line in lines:
f.write(line + '\n')
so putting this altogether you have
DELITEM():
lines = []
kw = Dele.get()
with open('notify.txt', 'r') as f:
if kw in f.read:
lines = f.readlines()
for i in range(len(lines)):
if kw in lines[i]:
print("The line is",i)
del lines[i]
break
with open('notify.txt', 'w') as f:
for line in lines:
f.write(line + '\n')