I want to print next and previous row , Here is my code
import csv
file= "myfile.txt"
searchname=input("Enter the name to be searched:")
f=open(file,'r')
reader=csv.reader(f)
lst=[]
for row in reader:
lst.append(row)
q=0
for row in lst:
if searchname in row:
print(row)
q+=1
f.close()
myfile.txt :
python,programming
java,programming
html,webdesigning
php,programming
I can Search "html" in python :
The Output is ['html','webdesigning']
But I want to print
['java','programming']
['html','webdesigning']
['php','programming']
It is Possible?? Anyone Have an Answer??
pls help!
enumerateas a helper because it give you the current index, but beware: the first and last rows are corner cases.