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
The error is:
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'
>>>
How do I make it so my code recalculates the previous item quantities and units for the new number of people?
Thanks
You
recipe
variable is a container which not carry all integer value, so when you usetypecasting
over your sequence thencasting
raisesliteral error
take a look:-