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