Advertisement
bl00dt3ars

blacklist

Jul 10th, 2021
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.42 KB | None | 0 0
  1. friends = input().split(', ')
  2.  
  3. # blacklisted = 0
  4. # lost = 0
  5.  
  6. input_command = input()
  7. while not input_command == "Report":
  8.     args = input_command.split()
  9.     command = args[0]
  10.  
  11.     if command == "Blacklist":
  12.         name = args[1]
  13.         if name in friends:
  14.             for i in range(len(friends)):
  15.                 if friends[i] == name:
  16.                     friends[i] = "Blacklisted"
  17.             print(f"{name} was blacklisted.")
  18.             # blacklisted += 1
  19.         else:
  20.             print(f"{name} was not found.")
  21.  
  22.     elif command == "Error":
  23.         index = int(args[1])
  24.         name = friends[index]
  25.         if 0 <= index < len(friends):
  26.             if friends[index] != "Lost" and friends[index] != "Blacklisted":
  27.                 friends[index] = "Lost"
  28.                 print(f"{name} was lost due to an error.")
  29.                 # lost += 1
  30.  
  31.     elif command == "Change":
  32.         index = int(args[1])
  33.         new_name = args[2]
  34.         if 0 <= index < len(friends) and friends[index] != "Lost" and friends[index] != "Blacklisted":
  35.             print(f"{friends[index]} changed his username to {new_name}.")
  36.             # current_username = friends[index]
  37.             friends[index] = new_name
  38.             # friends.insert(index, new_name)
  39.  
  40.     input_command = input()
  41.  
  42. print(f"Blacklisted names: {friends.count('Blacklisted')}")
  43. print(f"Lost names: {friends.count('Lost')}")
  44. print(' '.join(friends))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement