Dec-12-2018, 09:31 PM
(Dec-12-2018, 09:24 PM)misha Wrote:for i in data: myDict[i[0]] = {i[1]: i[2]}
Instead of setting the dict's value to a dict, set the sub-dict's value, and then make sure there's a sub-dict you can access. Also, use better variable names lol
for key, sub_key, value in data: if key not in myDict: myDict[key] = {} myDict[key][sub_key] = valueAlso...
(Dec-12-2018, 09:24 PM)misha Wrote: data = list(map(lambda x: x.split(), fin.readlines()))You can use str.split directly:
data = list(map(str.split, fin.readlines()))