Advertisement
Guest User

Untitled

a guest
Jun 18th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. import json
  2.  
  3. a = json.loads(input())
  4.  
  5. x = {}
  6.  
  7. for item in a["response"]["items"]:
  8.     if "bdate" not in item:
  9.         continue
  10.     mdy = item["bdate"].split(".")
  11.     if len(mdy) == 3:
  12.         year = int(mdy[2])
  13.         age = 2018 - year
  14.  
  15.         if age in x:
  16.             x[age] += 1
  17.         else:
  18.             x[age] = 1
  19.  
  20. out = list(x.items())
  21. out.sort()
  22.  
  23. print(sorted(out, key=lambda b: -b[1]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement