i am wondering how you would extract a text into dictionary in python. the text file is formatted as such(see below) and extract in way so that object earth for example is t
Assuming you want elements with comma-separated values as lists, try:
mydict={}
with open(my_file,'r') as the_file:
for line in the_file:
if not line.strip(): continue # skip blank lines
key,val=line.split(": ")
val = val.split(",")
mydict[key] = val if len(val) > 1 else val[0]