收起
图中代码主要问题是函数addToInventory没有返回值,导致在后面调用时空对象为不可迭代的提示错误。只需要将addToInventory函数的最后一句改一下即可,将print(inventory)改成 return inventory。
如有帮助,请点采纳。
报告相同问题?