Advertisement
bl00dt3ars

3

Aug 15th, 2021
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. information = {}
  2.  
  3. command = input()
  4. while not command == 'Log out':
  5.     command = command.split(': ')
  6.     if command[0] == 'New follower':
  7.         if command[1] not in information:
  8.             information[command[1]] = 0
  9.     elif command[0] == 'Like':
  10.         if command[1] not in information:
  11.             information[command[1]] = int(command[2])
  12.         else:
  13.             information[command[1]] += int(command[2])
  14.     elif command[0] == 'Comment':
  15.         if command[1] not in information:
  16.             information[command[1]] = 1
  17.         else:
  18.             information[command[1]] += 1
  19.     elif command[0] == 'Blocked':
  20.         if command[1] not in information:
  21.             print(f"{command[1]} doesn't exist.")
  22.         else:
  23.             information.pop(command[1])
  24.     command = input()
  25.  
  26. print(f'{len(information)} followers')
  27. for k, v in sorted(information.items(), key=lambda kvp: (-kvp[1], kvp)):
  28.     print(f'{k}: {v}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement