I think it's best if you modify the list without passing it into a no-return function. This involves python mutable variable, reference and scope.
Essentially, you might think a list can be passed into a function and have its values changed within the function, but it should remain unchanged outside the function. However that's not how python list works.
For example:
def temp(data):
data.clear()
data1 = [1,2,3]
temp(data1)
print(data1)
# output:
[]
The short version is that python variables are refered by their id, and passing a list as-is (just passing the name, as example show) into a function means that now list inside the function and outside the function shares same id, which means modification done within the function will affect list outside the function. (same behavior when you pass a list into multiple different function, now every function is modifying that list)
Also, depending on how you modify the list, sometimes a new id can be generated, which can mess up the logic even more.
I think the best way is to pass a copy of the original list (so that function uses a list with same value but different id, meaning all modification will not reflect to the original list), and have the function return the new list. Then assign the new return to your variable
ps. passing a copy of a list means that you're duplicating value and taking more memory, but it's really not that significant unless you have a 1GB list. If so, passing it in without .copy() and use new value from function return also works.
def process_list(data):
# code provided by other answers
return data
inventory = process_list(inventory.copy())
This way it's more clear about how the value are being changed