0

It only asks me to re-enter my age once. And then stops i want it to keep on asking me to re enter my age until my ages is between 11 and 18.

Enter your age from 11 to 18: 25
Please Re-Enter your Age: 2
after one re entry it breaks, it doesn't keep on asking me. 
i want it to ask me infinitely until its between 11-18

Enter your age from 11 to 18: 25
Please Re-Enter your Age: 2
after one re entry it breaks, it doesn't keep on asking me. 
i want it to ask me infinitely until its between 11-18

age = int(input('Enter your age from 11 to 18: '))
if age > 10 and age < 19:
  print(age)
else:
  input('Please Re-Enter your Age: ')

i expect to ask forever until it meets the condition.

ncica
  • 7,015
  • 1
  • 15
  • 37
  • 3
    Possible duplicate of [Asking the user for input until they give a valid response](https://stackoverflow.com/questions/23294658/asking-the-user-for-input-until-they-give-a-valid-response) – walnut Sep 16 '19 at 11:53

1 Answers1

1

Put it in a while loop, and break when correct like this:

while True:
    age = int(input('Enter age from 11 to 18 '))
    if age > 10 and age < 19:
        print(age)
        break
Shadesfear
  • 749
  • 4
  • 17