Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # WITHOUT JUDGE TESTING !
- # 02. Friends_maintenance , Mid Exam Fundamentals Python June.2022
- def is_index_valid(some_list, some_index):
- if 0 <= some_index < len(some_list):
- return True
- return False
- def is_name_valid(some_list, some_name):
- if (some_name in some_list) and (some_name != 'Blacklisted') and (some_name != 'Lost'):
- return True
- return False
- data = input().split(", ")
- command = input()
- blacklisted_names = []
- lost_names = []
- while not command == 'Report':
- details = command.split(' ')
- if details[0] == 'Blacklist':
- move_to_blacklist = details[1]
- if move_to_blacklist in data:
- index_name = data.index(move_to_blacklist)
- data[index_name] = 'Blacklisted'
- blacklisted_names.append(move_to_blacklist)
- print(f'{move_to_blacklist} was blacklisted.')
- else:
- print(f'{move_to_blacklist} was not found.')
- elif details[0] == 'Error':
- index = int(details[1])
- name = data[index]
- if is_index_valid(data, index) and is_name_valid(data, name):
- data[index] = 'Lost'
- print(f'{name} was lost due to an error.')
- lost_names.append(name)
- elif details[0] == 'Change':
- change_index = int(details[1])
- new_name = details[2]
- if is_index_valid(data, change_index):
- data[change_index] = new_name
- command = input()
- print(f'Blacklisted names: {len(blacklisted_names)}')
- print(f'Lost names: {len(lost_names)}')
- print(' '.join(data))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement