Lets say I have a dictionary:
dict = {"A":"a", "B":"b"}
I would like to make a new list which is named after the value of key "B", and than pot original dictionary inside the new list.
b =(dict)
thanks!
Lets say I have a dictionary:
dict = {"A":"a", "B":"b"}
I would like to make a new list which is named after the value of key "B", and than pot original dictionary inside the new list.
b =(dict)
thanks!
You can use globals(). For your dictionary i used the name your_dict as dict could cause issues due to the built in method dict:
your_dict = {"A":"a", "B":"b"}
globals()[your_dict['B']]=your_dict
print(b)
Output:
{"A":"a", "B":"b"}