Advertisement
Spocoman

03. Inventory

Nov 4th, 2023
647
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. collected_items = input().split(", ")
  2. input_line = input()
  3.  
  4. while input_line != "Craft!":
  5.     command, item = input_line.split(" - ")
  6.     if command == "Collect":
  7.         if item not in collected_items:
  8.             collected_items.append(item)
  9.     elif command == "Drop":
  10.         if item in collected_items:
  11.             collected_items.remove(item)
  12.     elif command == "Combine Items":
  13.         old_item, new_item = item.split(':')
  14.         if old_item in collected_items:
  15.             collected_items.insert(collected_items.index(old_item) + 1, new_item)
  16.     else:
  17.         if item in collected_items:
  18.             collected_items.append(collected_items.pop(collected_items.index(item)))
  19.     input_line = input()
  20.  
  21. print(", ".join(collected_items))
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement