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