Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tanks = [x for x in input().split(", ")]
- n = int(input())
- for i in range(n):
- tokens = [x for x in input().split(', ')]
- cmd = tokens[0]
- if 'Add' in cmd:
- name = tokens[1]
- if name in tanks:
- print('Tank is already bought')
- else:
- print('Tank successfully bought')
- tanks.append(name)
- elif 'Remove At' in cmd:
- idx = int(tokens[1])
- if 0 <= idx < len(tanks):
- print('Tank successfully sold')
- tanks.pop(idx)
- else:
- print('Index out of range')
- elif 'Remove' in cmd:
- name = tokens[1]
- if name in tanks:
- print('Tank successfully sold')
- tanks.remove(name)
- else:
- print('Tank not found')
- elif 'Insert' in cmd:
- idx = int(tokens[1])
- new_tank = tokens[2]
- if 0 <= idx < len(tanks):
- if new_tank in tanks:
- print('Tank is already bought')
- else:
- print('Tank successfully bought')
- tanks.insert(idx, new_tank)
- else:
- print('Index out of range')
- print(', '.join(tanks))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement