I have a txt file and I want to read values into a dictionary. Different from common dictionary, the value of each key
is a value pair, for example:
tiger eat meat
tiger eat people
rabbit eat carrot
people can walk
trees has root
people has hand
I want to get a dictionary that,
tiger, {eat, meat}, {eat, people}
rabbit, {eat, carrot}
trees, {has, root}
people, {can, walk}, {has, hand}
Should I just read lines
, split(\n)
into 3 items and store the first one as the key and the rest two ones as the values? Or there is a better way to store the two values?
My objective is that, when I query what does a tiger eat, I want to get the answer meat
and people
.