Reputation: 6709
Hi I have this code...
x = {'stack': ['2', '3'], 'overflow': ['1', '2']}
for i in x.values():
heroes = {x[0]:x[1:] for x in permutations(i)}
print heroes
This gives me...
{'3': ('2',), '2': ('3',)}
{'1': ('2',), '2': ('1',)}
Later on in my program I need the values of the keys to be in list form, not tuple form. So the result I need is this...
{'3': ['2'], '2': ['3']}
{'1': ['2'], '2': ['1']}
How can I modify my code to give me this result while maintaining efficieny? Thanks a bunch.
Upvotes: 1
Views: 259