print("\nPlease input the quantity to borrow,Enter to return:")
need = int(input())
if need > ITEMS[i][INDEX_ITEM_TOTAL_QAUNTITY] or need <= 0:
print("\nInvalid value for quantity.")
else:
temp = list(ITEMS)
temp[i][INDEX_ITEM_TOTAL_QAUNTITY] = temp[i][INDEX_ITEM_TOTAL_QAUNTITY]-need
ITEMS[i][INDEX_ITEM_TOTAL_QAUNTITY] = tuple(temp[i][INDEX_ITEM_TOTAL_QAUNTITY])
print("Success!")
结果如下
temp[i][INDEX_ITEM_TOTAL_QAUNTITY] = temp[i][INDEX_ITEM_TOTAL_QAUNTITY]-need
TypeError: 'tuple' object does not support item assignment
下