bl00dt3ars

Biscuits

Mar 6th, 2021 (edited)
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. biscuits = input().split(', ')
  2. command = input()
  3.  
  4. while command != 'Eat':
  5.     current_command = command.split()
  6.     if current_command[0] == 'Update-Any':
  7.         if current_command[1] in biscuits:
  8.             for i in range(len(biscuits)):
  9.                 if biscuits[i] == current_command[1]:
  10.                     biscuits[i] = "Out of stock"
  11.  
  12.     elif current_command[0] == 'Remove':
  13.         if 0 <= int(current_command[2]) < len(biscuits):
  14.             biscuits[int(current_command[2])] = current_command[1]
  15.  
  16.     elif current_command[0] == 'Update-Last':
  17.         biscuits[len(biscuits) - 1] = current_command[1]
  18.  
  19.     elif current_command[0] == 'Rearrange':
  20.         if current_command[1] in biscuits:
  21.             for i in range(len(biscuits)):
  22.                 if biscuits[i] == current_command[1]:
  23.                     biscuits.pop(i)
  24.                     biscuits.append(current_command[1])
  25.  
  26.     command = input()
  27.  
  28. biscuits = [el for el in biscuits if "Out of stock" not in el]
  29. print(' '.join(biscuits))
Add Comment
Please, Sign In to add comment