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