viligen

friend_list_maintenance

Oct 25th, 2021
675
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. friends = input().split(", ")
  2.  
  3. while True:
  4.     command = input().split()
  5.     if "Report" in command:
  6.         break
  7.     elif "Blacklist" in command:
  8.         name = command[1]
  9.         if name in friends:
  10.             index = friends.index(name)
  11.             friends[index] = "Blacklisted"
  12.             print(f"{name} was blacklisted.")
  13.         else:
  14.             print(f"{name} was not found.")
  15.     elif "Error" in command:
  16.         index = int(command[1])
  17.         if 0 <= index < len(friends) and friends[index] != "Blacklisted" and friends[index] != "Lost":
  18.             print(f"{friends[index]} was lost due to an error.")
  19.             friends[index] = "Lost"
  20.     elif "Change" in command and 0 <= int(command[1]) < len(friends):
  21.         index_old = int(command[1])
  22.         new_name = command[2]
  23.         print(f"{friends[index_old]} changed his username to {new_name}.")
  24.         friends[index_old] = new_name
  25.  
  26. count_blacklisted = len([s for s in friends if s == "Blacklisted"])
  27. count_lost = len([s for s in friends if s == "Lost"])
  28. print(f"Blacklisted names: {count_blacklisted}")
  29. print(f"Lost names: {count_lost}")
  30. print(*friends)
  31.  
RAW Paste Data