Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- chest = input().split('|')
- counter = 0
- while True:
- text = input().split()
- command = text[0]
- if command == 'Yohoho!':
- break
- elif command == 'Loot':
- for item in text[1::]:
- if item not in chest:
- chest.insert(0, item)
- elif command == 'Drop':
- index = int(text[1])
- if 0 <= index < len(chest):
- chest.append(chest.pop(index))
- elif command == 'Steal':
- stolen = []
- count = int(text[1])
- if count <= len(chest):
- stolen = chest[-count ::]
- for i in range(count):
- chest.pop()
- else:
- stolen = chest.copy()
- chest.clear()
- print(', '.join(stolen))
- else:
- break
- if chest:
- credit = 0
- for item in chest:
- counter += len(item)
- credit = counter / len(chest)
- print(f'Average treasure gain: {credit:.2f} pirate credits.')
- else:
- print('Failed treasure hunt.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement