-3
num=int(input("Enter a number between 10 and 20."))
    while num<10 or num>20:
        num1=int(input("Enter a number between 10 and 20."))
        if 10<num<20:
        break
print("Well done!")

The loop is infinite cannot escape. Output is always (num1) not sure what I'm doing wrong.

1 Answers1

2

The loop is infinite because it tests the value of num (which we already know is outside the acceptable range when we enter the loop).

But num does not change within the loop - the input only modifies num1.

DNA
  • 42,007
  • 12
  • 107
  • 146