search = "-"; f = open('MyText.txt', 'r') text=f.read() text=text.replace(" ","") listofstrings=text.split(".", len(text)) counter=0 searchcount=0 while counter<len(listofstrings): if listofstrings[counter][0]==search: searchcount+=1 print(listofstrings[counter]) counter+=1 if searchcount==0: print("\nНе нашел(\n") else: print("Было найдено: ") print(searchcount) f.close() 

if listofstrings [counter] [0] == search: in this line, the interpreter error says that this value is out of range, the text is called the lohr

  • one
    How do you think, how many elements have an empty string? - 0andriy
  • Kst, but why is there istofstrings=text.split(".", len(text)) second parameter? - gil9red

0