为什么我的 while 循环不添加总值

Why is my while loop not adding the values for the total

我有一些用于 for 循环的代码,但它不允许我添加值,即总计 +=1。

如果那是正确的缩进,那么您只会添加在无效输入后输入的值

取消缩进附加到总重量的行

while foodweight<0 or foodweight>200:
    print("Invalid, weight cant be less than 0 or more than 200")
    foodweight=int(input("Please enter the actual weight of the food:'"))
totalweight+=foodweight