Advertisement
bl00dt3ars

Biscuits (2)

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