Advertisement
jinhuang1102

Untitled

Dec 17th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. from collections import defaultdict
  2. from random import seed
  3. import random
  4.  
  5. def rand():
  6.     return random(0, 10)
  7.  
  8.  
  9. map = defaultdict(int)
  10. for i in range(0, 26):
  11.     key = chr(ord('A') + i)
  12.     map[key] = random.randint(0, 10)
  13.  
  14. print(map)
  15.  
  16. for key in map:
  17.     print(key, map[key])
  18.  
  19. reduce = defaultdict(list)
  20. for key in map:
  21.     reduce[map[key]].append(key)
  22.  
  23. print(reduce)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement