hello,
in my home work I need to write a function that gets text file and work
and have to find the first time that the word appears and retuen (a,b)
whereas a = number of line b= nuber of word in line.
in addition if theres any functuations they need to be deleted and if somone serach for the word key and it exixt with uppercase they still could find it. ive tried to do it but doesnt work it returns me none:(
ive wrote:
in my home work I need to write a function that gets text file and work
and have to find the first time that the word appears and retuen (a,b)
whereas a = number of line b= nuber of word in line.
in addition if theres any functuations they need to be deleted and if somone serach for the word key and it exixt with uppercase they still could find it. ive tried to do it but doesnt work it returns me none:(
ive wrote:
def finds(word,filename) count=0 word=word.lower() f=open(filename,'r') k=f.readlines() for j in range(len(k)): for t in range(len(k[j].split())): if k[j].split()[t].isdigit()==False or k[j].split()[t].isalpha()==False: k[j].split()[t]=k[j].split()[t].lower().rstrip['!@,./;'] if word==k[j].split()[t]: b=j+1 count=t+1 return (count,b)thanks!