I am writing a code where program read data from file and then it readlines and if a specific word exist in list it allows the user to modify its quantity. Well the issue is how can i get the iteration number (line number) in for loop while it is searching for word in line
My Code:
f= open('guru99.txt','r')
action = int(input('Enter number'))
if action == 1:
for line in lines:
if 'banana' in line:
print(line)
print('You already purchased banana! You can change the quantity')
edit = line.split()
qty = int(input('Enter new quanity'))
print(bline)
else:
continue
for example if the word banana found on line number 3. How to edit this program to show the iteration number or index of the for loop