我觉得自己很笨,但如何定位数组的元素并向其中添加一个元素呢?问题是向购物车添加项目和数量。所以我需要在数量上加一个,这是第二个输入。i、 e.多数组将包含[项目][数量]
else:
print ("That item is already in your cart")
add = input("Want to add one more to your cart?")
if add == "yes":
addItem(strChoice)
def addItem(strChoice):
#TO DO
#Find the strChoice in the aryCart and then add one to the qty
for i in strChoice:
aryCart = [strChoice][i+1]
需要注意的事项: 是的,你需要提供额外的代码,这是一个例子。 aryCart必须是字典而不是数组。 下面是一个例子,它需要如何做
相关问题 更多 >
编程相关推荐