I’m pretty new to python, and I want to create a list from a dictionary.
If I had a dictionary declared like this:
a = {"e1" : "Hello", "e2" : "Hi"}
I would want to get a list like this:
a = [["e1", "Hello"], ["e2", "Hi"]]
I honestly don’t know how I would even start to do this so I don’t have any code to help.
>Solution :
You can use a for loop in the dictionary .keys() method like this:
a = {"e1" : "Hello", "e2" : "Hi"}
b = []
for key in a.keys():
b.append([key, a[keys]])