fork download
  1. from collections import defaultdict
  2.  
  3.  
  4. values = ['python', 'proj', 'proj']
  5.  
  6. d = defaultdict(list)
  7. for v in values:
  8. d[v].append(v)
  9.  
  10. print(dict(d))
Success #stdin #stdout 0.02s 9392KB
stdin
Standard input is empty
stdout
{'proj': ['proj', 'proj'], 'python': ['python']}