Advertisement
George_Ivanov05

0.2

Jul 9th, 2021
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.89 KB | None | 0 0
  1. loot = input().split("|")
  2. command = input().split()
  3.  
  4. while not command[0] == "Yohoho!":
  5.     if command[0] == "Loot":
  6.         for el in range(1, len(command)):
  7.             if command[el] not in loot:
  8.                 loot.insert(0, command[el])
  9.     elif command[0] == "Drop":
  10.         if 0 <= int(command[1]) < len(loot):
  11.             loot.append(loot[int(command[1])])
  12.             loot.pop(int(command[1]))
  13.     elif command[0] == "Steal":
  14.         if int(command[1]) >= len(loot):
  15.             print(", ".join(loot))
  16.             loot = []
  17.         else:
  18.             print(", ".join(loot[len(loot) - int(command[1]):]))
  19.             loot = loot[:len(loot) - int(command[1])]
  20.     command = input().split()
  21.  
  22. if len(loot) == 0:
  23.     print("Failed treasure hunt.")
  24. else:
  25.     average_gain = sum([len(el) for el in loot]) / len(loot)
  26.     print(f"Average treasure gain: {average_gain:.2f} pirate credits.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement