Advertisement
GeorgiLukanov87

03. Inventory

May 18th, 2022
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. collection = input().split(', ')
  2. command = input()
  3.  
  4. while not command == 'Craft!':
  5.     command = command.split(' - ')
  6.    
  7.     if command[0] == 'Collect':
  8.         item = command[1]
  9.         if item not in collection:
  10.             collection.append(item)
  11.            
  12.     elif command[0] == 'Drop':
  13.         item = command[1]
  14.         if item in collection:
  15.             collection.remove(item)
  16.            
  17.     elif command[0] == 'Combine Items':
  18.         to_combine = command[1].split(':')
  19.         old_item = to_combine[0]
  20.         new_item = to_combine[1]
  21.         for indx in range(len(collection)):
  22.             if old_item == collection[indx]:
  23.                 collection.insert(indx + 1, new_item)
  24.                
  25.     elif command[0] == 'Renew':
  26.         item = command[1]
  27.         for indx in range(len(collection)):
  28.             if item == collection[indx]:
  29.                 collection.remove(item)
  30.                 collection.insert(len(collection), item)
  31.  
  32.  
  33.     command = input()
  34. print(', '.join(collection))
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement