I am using a while loop inside a if / else condition. For some reason under one condition the while loop does not work. The condition is shown in my code below. Under these conditions I would assume that the else condition should be utilized and the weight and the max_speed should be decreased until both while conditions are not valid anymore. What am I doing wrong?
weight = 0
max_speed = 15
if weight == 0 and max_speed <= 10:
while weight == 0 and max_speed <= 10:
weight=weight+1
print(weight)
print(max_speed)
else:
while weight != 0 and max_speed > 10:
weight = weight-1
max_speed=max_speed-1
print(weight)
print(max_speed)
elsebranch but since weight is0theweight != 0evaluates toFalseand therefore the wholeweight != 0 and max_speed > 10expression evaluates toFalse. And that is why thewhileloop doesn't run.weight=0andmax_speed=10??ifandelseconditions. Whatever you want to achieve, you should use moreelse-statements or useorinstead ofandto cover all combination of the 2 variables weight and max_speed.