Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- my_dict = {}
- while True:
- string = input()
- if string == "Log out":
- break
- else:
- token = string.split(": ")
- command = token[0]
- if command == "New follower":
- username = token[1]
- if username in my_dict:
- pass
- else:
- my_dict[username] = 0
- elif command == "Like":
- username = token[1]
- count = int(token[2])
- if username not in my_dict:
- my_dict[username] = 0
- my_dict[username] += count
- elif command == "Comment":
- username = token[1]
- if username not in my_dict:
- my_dict[username] = 0
- my_dict[username] += 1
- elif command == "Blocked":
- username = token[1]
- if username not in my_dict:
- print(f"{username} doesn't exist.")
- else:
- my_dict.pop(username)
- print(f"{len(my_dict)} followers")
- for key, value in sorted(my_dict.items(), key= lambda x: (-x[1], x[0])):
- print(f"{key}: {value}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement