Create A Dictionary With Name Of Variable
I am trying to write a program to parse a file, break it into sections, and read it into a nested dictionary. I want the output to be something like this: output = {'section1':{'ne
Solution 1:
You can name a dictionary entry from a variable. If you have
text = "myKey"# or myNumber or any hashable typedata = dict()
You can do
data[text] = anyValue
Post a Comment for "Create A Dictionary With Name Of Variable"