What I mean about the logic is that it only shows you searching for an empty slot and adding one item to the inventory on start of layout. It sounds like you are storing items to later add to an array, why not add to the array at the moment they are picked up?
There would only be one global var to store an item as you pick it up, but once you have verified it is working you wouldn't even need that. With the function, if you are making an add item function, you can send the item name through the function as a parameter. Read up on functions if you don't know about this.
What you've done here is combine looking for the empty row and adding the item into one function which is fine but I don't understand the use of dictionaries and list of items.
I would advise using debugging with the Browser object, you can log things to the console to check how the function is working.