-2

This has been driving me up the wall and I really could use some help. So, as I mentioned in the title, I have a dictionary that looks as follows:

frozenset({2}) 3
frozenset({1}) 3
frozenset({5}) 3
frozenset({3}) 3
frozenset({1, 2}) 3
frozenset({2, 5}) 3
frozenset({2, 3}) 3
frozenset({1, 5}) 3
frozenset({1, 3}) 3
frozenset({3, 5}) 3
frozenset({1, 2, 5}) 3
frozenset({2, 3, 5}) 3

that I want to convert into a list of dictionaries where it would look like this:

[
{[2]: 3},
{[1]: 3},
{[5]: 3},
{[3]: 3}, 
{[1, 2]: 3},
{[2, 5]: 3},
{[2, 3]: 3},
{[1, 5]: 3},
{[1, 3]: 3},
{[3, 5]: 3},
{[1, 2, 5]: 3},
{[2, 3, 5]: 3}
]

I've tried to put the keys and values into lists and then convert the keys into lists but for some reason I keep getting frozensets. I don't know how to go from here. Thanks for reading and I hope you could help me out.

Reem H
  • 3
  • 3

1 Answers1

1

You can't have lists as dictionary keys as they are a mutable type and only immutable types can be used as dict keys.

If you'd like to know more, find out: why dict keys must be immutable.

scr
  • 853
  • 1
  • 2
  • 14