to preface, this issue arises within a while loop, inside a for loop, inside a function. The while loop is supposed to take an input from the user and break once a set variable is discovered (a number between 1 and 5) however, when I was bug fixing I found that it would loop on a negative, say -9, but if I put in a positive, say 9, then a negative, it would break the loop. I am super stumped on what I have done that allows this bypass as it will loop infinitely in the negatives and the positives, but doesn't loop infinitely if a positive is input followed by a negative.
while food.isdigit() == True:
if int(food) >= 1 and int(food) <= 5:
break
else:
print (invalid_score)
food = input(f"Critic {number} Food Score: ")
I have tried the following but it still breaks the while loop after taking an incorrect positive integer followed by an incorrect negative integer.
while food.isdigit() == True:
if int(food) >= 1 and int(food) <= 5:
break
elif int(food) < 1 or int(food) > 5:
print (invalid_score)
food = input(f"Critic {number} Food Score: ")