Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- loot = input().split("|")
- while True:
- command = input().split()
- if "Yohoho!" in command:
- break
- elif "Loot" in command:
- items = command[1:]
- for item in items:
- if item not in loot:
- loot.insert(0, item)
- elif "Drop" in command and 0 <= int(command[1]) < len(loot):
- removed = loot.pop(int(command[1]))
- loot.append(removed)
- elif "Steal" in command and int(command[1]) > 0:
- count = int(command[1])
- stolen = loot[-count:]
- loot = loot[:-count]
- print(", ".join(stolen))
- if len(loot) == 0:
- print("Failed treasure hunt.")
- else:
- lens = [int(len(s)) for s in loot]
- average = sum(lens)/len(loot)
- print(f"Average treasure gain: {average:.2f} pirate credits.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement