0

Given a dictionary in Python:

{u'100': 0, u'200': 1, u'300': 2, u'100': 1, u'400': 1, u'400': 1, u'500': 1}

How can I create a new dictionary that reverses the key and value:

{0: [u'100'], 1: [u'200', u'100', u'400', u'400', u'500'], 2: [u'100']}

Aoitori
  • 67
  • 2
  • 8
  • I think easiest (not optimal) way is iterate on dict, and to each value as key in new dict, assign key from first dict. – darvark Mar 19 '17 at 15:29
  • The [third highest-voted answer](http://stackoverflow.com/a/485368) on the duplicate explains how to create lists of non-unique keys per value. – Martijn Pieters Mar 19 '17 at 15:29

0 Answers0