Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def is_valid_index(list, index):
- if 0 <= index < len(list):
- return True
- friends = input().split(', ')
- counter_blacklisted = 0
- counter_error = 0
- command = input().split()
- while not command[0] == 'Report':
- action = command[0]
- if action == 'Blacklist':
- name = command[1]
- if name in friends:
- friends[friends.index(name)] = 'Blacklisted'
- counter_blacklisted += 1
- print(f'{name} was blacklisted.')
- else:
- print(f"{name} was not found.")
- elif action == 'Error':
- index = int(command[1])
- if is_valid_index(friends, index):
- if not friends[index] == 'Blacklisted' and not friends[index] == 'Lost':
- print(f'{friends[index]} was lost due to an error.')
- friends[index] = 'Lost'
- counter_error += 1
- elif action == 'Change':
- index = int(command[1])
- new_name = command[2]
- if is_valid_index(friends, index):
- print(f'{friends[index]} changed his username to {new_name}')
- friends[index] = new_name
- command = input().split()
- print(f"Blacklisted names: {counter_blacklisted}")
- print(f"Lost names: {counter_error}")
- print(*friends)
Advertisement
Add Comment
Please, Sign In to add comment