Python Forum

Full Version: Validating user input
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am new to Python and do not know how to do the following:

I have an input statement asking the user to enter 4 values. I then validate these values and if anyone fails the validation, I need the user to re-enter the values.

What construct can I use to do this (since Python does not have a goto!)?
Without code, it is difficult to see what kind of validation you need.
Paul
Basic example might be like this:
while True:
    name = input('a name: ')
    if name == 'John':
        print('true')
        break
    else:
        print('False')
        continue
Output:
a name: bob Incorrect. Try again. a name: John true