I am using Python 3.3. I was curious how I can make a dictionary out of a list:
Lets say my list containing strings is
list = ['a;alex', 'a;allison', 'b;beta', 'b;barney', 'd;doda', 'd;dolly']
I want to make it into a dictionary like this:
new_dict = { {'a': {'alex','allison'}}
{'b': {'beta','barney'}}
{'d': {'doda', 'dolly'}} }
so later I can print it out like this:
Names to be organized and printed:
a -> {'alex', 'allison'}
b -> {'beta', 'barney'}
d -> {'doda', 'dolly'}
How would I approach this? Many thanks in advance!
-UPDATE-
So far I have this:
reached_nodes = {}
for i in list:
index = list.index(i)
reached_nodes.update({list[index][0]: list[index]})
But it outputs into the console as:
{'a': 'a;allison', 'b': 'b;barney', 'd': 'd;dolly'}