Task: given a txt file with adjective \t synonym, synonym, synonym, etc. in a line, several lines are given. I need to create a dictionary, where adjective will be a key and synonyms - a value. My code:
#necessary for command-line
import sys
#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
dict = {}
#for each line in filename
for line in filename:
#key is everything before tab, value - after the tab
key, value = line.strip().split("\t")
dict[key.strip()] = value.strip()
#close the file
filename.close()
Terminal shows the error:
key, value = line.strip().split("\t")
ValueError: not enough values to unpack (expected 2, got 1)
Could someone help to fix?