Задача: дан txt файл с прилагательным \t синонимом, синонимом, синонимом и т.д. в строке, дано несколько строк. Мне нужно создать словарь, где прилагательное будет ключом, а синонимы - значением. Мой код:
#necessary for command line + regex
import sys
import re
#open file for reading
filename = sys.argv[1]
infile = open(filename, "r")
#a
#create a dictionary, where an adjective in a line is a key
#and synonyms are the value
dictionary = {}
#for each line in infile
for line in infile:
#creating a list with keys, a key is everything before the tab
adjectives = re.findall(r"w+\t$", line)
print(adjectives)
#creating a list of values, a value is everything after the tab
synonyms = re.findall(r"^\tw+\n$", line)
print(synonyms)
#combining both lists into a dictionary, where adj are keys, synonyms - values
dictionary = dict(zip(adjectives, synonyms))
print(dictionary)
#close the file
infile.close()
Вывод показывает мне пустые скобки... Может ли кто-нибудь помочь исправить?