print("For this recipe ", recipe[0], "for ", recipe[1])
print("You will need the following Ingredients with quantities and units: ")
Index = 2
while (Index != len(recipe)) :
print(recipe[Index])
Index = Index+1
calculatedIQuantity = int(recipe[Index]) / int(recipe[1]) * int(peopleNo)
print(calculatedIQuantity)
Index = Index+1
print(recipe[Index])
Index = Index+1
错误是:
Traceback (most recent call last):
File "\\server\examuser41\test1.py", line 78, in <module>
viewer()
File "\\server\examuser41\test1.py", line 70, in viewer
calculatedIQuantity = int(recipe[Index]) / int(recipe[1]) * int(peopleNo)
ValueError: invalid literal for int() with base 10: 'cm\n'
>>>
如何使我的代码为新的人数重新计算以前的项目数量和单位?
谢谢