Guest User

Untitled

a guest
Nov 24th, 2021
57
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. loot = input().split('|')
  2. sum_items = 0
  3.  
  4. while True:
  5.     command = input().split()
  6.     if command[0] == 'Yohoho!':
  7.         break
  8.  
  9.     elif command[0] == 'Loot':
  10.         for i in range(len(command)):
  11.             if i == 0:
  12.                 continue
  13.             item = command[i]
  14.             if item not in loot:
  15.                 loot.insert(0, item)
  16.  
  17.     elif command[0] == 'Drop':
  18.         idx = int(command[1])
  19.         if 0 <= idx < len(loot):
  20.             x = loot.pop(idx)
  21.             loot.append(x)
  22.         else:
  23.             continue
  24.  
  25.     elif command[0] == 'Steal':
  26.         n = int(command[1])
  27.         if n >= len(loot):
  28.             removed = loot
  29.             print(', '.join(removed))
  30.             print('Failed treasure hunt.')
  31.             exit()
  32.         else:
  33.             removed = loot[-n:]
  34.             del loot[-n:]
  35.             print(', '.join(removed))
  36.  
  37. if len(loot) > 0:
  38.     for i in range(len(loot)):
  39.         sum_items += len(loot[i])
  40.  
  41.     avg = f'{sum_items / len(loot):.2f}'
  42.     print(f'Average treasure gain: {avg} pirate credits.')
  43.  
  44.  
RAW Paste Data