Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- phones = input().split(', ')
- command = input().split(' - ')
- while not command[0] == 'End':
- action = command[0]
- if action == 'Add':
- phone = command[1]
- if phone not in phones:
- phones.append(phone)
- elif action == 'Remove':
- phone = command[1]
- if phone in phones:
- phones.remove(phone)
- elif action == 'Bonus phone':
- old_phone = command[1].split(':')[0]
- new_phone = command[1].split(':')[1]
- if old_phone in phones:
- phones.insert(phones.index(old_phone) + 1, new_phone)
- elif action == 'Last':
- phone = command[1]
- if phone in phones:
- phones.append(phones.pop(phones.index(phone)))
- command = input().split(' - ')
- print(*phones, sep=', ')
Advertisement
Add Comment
Please, Sign In to add comment