Advertisement
Guest User

Friendlist Maintenance

a guest
Jan 24th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. name_list = input()
  2. name_list = name_list.split(', ')
  3.  
  4. while True:
  5. command = input()
  6. command = command.split(' ')
  7.  
  8. if 'Report' in command:
  9. break
  10. elif 'Blacklist' in command:
  11. if len(command) >= 2:
  12. name = command[1]
  13. if name in name_list:
  14. i = name_list.index(name)
  15. name_list[i] = 'Blacklisted'
  16. print(f'{name} was blacklisted.')
  17. else:
  18. print(f"{name} was not found.")
  19. elif 'Error' in command:
  20. if len(command) >= 2:
  21. i = command[1]
  22. if len(i) == 1 and (48 <= ord(i) <= 57):
  23. i = int(i)
  24. if i < len(name_list):
  25. name = name_list[i]
  26. if name != 'Blacklisted' and name != 'Lost':
  27. name_list[i] = 'Lost'
  28. print(f"{name} was lost due to an error.")
  29. elif 'Change' in command:
  30. if len(command) >= 3:
  31. i = command[1]
  32. if len(i) == 1 and (48 <= ord(i) <= 57):
  33. i = int(i)
  34. if i < len(name_list):
  35. current_name = name_list[i]
  36. new_name = command[2]
  37. print(f"{current_name} changed his username to {new_name}.")
  38. name_list[i] = new_name
  39.  
  40. blacklistedNamesCount = name_list.count('Blacklisted')
  41. lostNamesCount = name_list.count('Lost')
  42.  
  43. print(f"Blacklisted names: {blacklistedNamesCount}")
  44. print(f"Lost names: {lostNamesCount}")
  45. print(' '.join(name_list))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement