from bs4 import BeautifulSoup import requests list_of_links = ['https://anrceti.md/directors', ] list_for_diacritics = ['Ă', 'ă', 'î', 'Î', 'â', 'Â', 'ș', 'Ș', 'ț', 'Ț'] link = "http://balti.md/primaria/aparatul-primariei/" search_word = input('Întroduceți numele sau prenumele: ').capitalize() r = requests.get(link) soup = BeautifulSoup(r.content) soup = soup.get_text() answer = None data = str(soup).split() if search_word in data: dictOfWords = {i: data[i] for i in range(0, len(data))} for name1, name2 in dictOfWords.items(): # for name, age in dictionary.iteritems(): (for Python 2.x) if name2 == search_word: print(str(name1) + ' ' + search_word + " " + link) print(name1 + 1) print(search_word + " " + dictOfWords[name1 + 1] + " " + link) print(dictOfWords[name1 - 1] + " " + search_word + " " + link) else: answer = 'sorry' print(answer) [/code]
https://imgur.com/a/FhMShOQ , сама ошибка, сравните с 1-ым скриншотом