Advertisement
simeonshopov

Friendlist Maintence

Jan 21st, 2020
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.11 KB | None | 0 0
  1. friend_list = input().split(", ")
  2.  
  3. command = input()
  4.  
  5. while command != "Report":
  6.     tokens = command.split(" ")
  7.     cmd = tokens[0]
  8.     name = tokens[1]
  9.     if cmd == "Blacklist":
  10.         idx = friend_list.index(name)
  11.         if name not in friend_list:
  12.             print(f"{name} was not found.")
  13.         else:
  14.             friend_list[idx] = "Blacklisted"
  15.             print(f"{name} was blacklisted.")
  16.     elif cmd == "Error":
  17.         idx = int(name)
  18.         if friend_list[idx] != "Blacklisted" and friend_list[idx] != "Lost":
  19.             print(f"{friend_list[idx]} was lost due to an error.")
  20.             friend_list[idx] = "Lost"
  21.     elif cmd == "Change":
  22.         new_name = tokens[2]
  23.         idx = int(name)
  24.         if 0 <= idx <= len(friend_list) - 1:
  25.             print(f"{friend_list[idx]} changed his username to {new_name}.")
  26.             friend_list[idx] = new_name
  27.     command = input()
  28.  
  29. blacklisted = [x for x in friend_list if x == "Blacklisted"]
  30. lost = [x for x in friend_list if x == "Lost"]
  31. print(f"Blacklisted names: {len(blacklisted)}\nLost names: {len(lost)}")
  32. print(" ".join(friend_list))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement