num = 0
word_dict = {}
// в теле цикла
if not (word in word_dict):
word_dict[num] = word
num = num + 1
with open('text_file', encoding='utf-8') as file:
sorted_list = sorted(word.rstrip() for word in file.readlines())
with open('text_file', encoding='utf-8') as file:
sorted_dict = {i: word.rstrip() for i, word in enumerate(file.readlines())}
with open('text_file', encoding='utf-8') as file:
sorted_list_with_index = sorted(
{i: word.rstrip() for i, word in enumerate(file.readlines())}.items(),
key=lambda x: x[1]
)