Erwy Lionel
Erwy Lionel

Reputation: 71

While loop for number's between 10 to 100

Trying to continue a while loop if false but I cannot figure it out I have this so far

int_a = input("Enter a interger from 10 and 100 :")
int_a = int(int_a)


# While greater than zero.
while int_a >=10:
    if int_a<=100:
       print ("The integer you entered is", int_a)
    break

Upvotes: 0

Views: 4543

Answers (1)

StenSoft
StenSoft

Reputation: 9617

Trying to continue a while loop if false

So while loop for numbers not between 10 and 100.

while True:
    int_a = input("Enter a interger from 10 and 100 :")
    int_a = int(int_a)

    if (10 <= int_a <= 100):
        # Correct number, break the while loop
        break

    # Wrong number
    print ("The integer you entered is wrong")
    # While loop restarts automatically here

# Here int_a is in the correct range
print ("The integer you entered is", int_a)

Upvotes: 1

Related Questions