Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- treasure_chest = input().split("|")
- command_data = input()
- while command_data != 'Yohoho!':
- command, *data = [int(x) if x.isdigit() else x for x in command_data.split()]
- if command == "Loot":
- for item in data:
- if item not in treasure_chest:
- treasure_chest.insert(0, item)
- elif command == "Drop":
- index = data[0]
- if index in range(len(treasure_chest)):
- item = treasure_chest.pop(index)
- treasure_chest.append(item)
- elif command == "Steal":
- index = -data[0]
- stolen_items = treasure_chest[index:]
- treasure_chest = treasure_chest[:index]
- print(', '.join(stolen_items))
- command_data = input()
- if treasure_chest:
- avr_treasure = sum(len(x) for x in treasure_chest) / len(treasure_chest)
- print(f'Average treasure gain: {avr_treasure:.2f} pirate credits.')
- else:
- print('Failed treasure hunt.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement