Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Validating user input
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.
Basic example might be like this:
while True:
    name = input('a name: ')
    if name == 'John':
a name: bob Incorrect. Try again. a name: John true

Possibly Related Threads…
Thread Author Replies Views Last Post
  Problem restricting user input in my rock paper scissors game ashergreen 6 546 Mar-25-2021, 03:54 AM
Last Post: deanhystad
  LinkedList by User Input SantiagoPB 5 711 Mar-03-2021, 09:54 PM
Last Post: deanhystad
  User input/picking from a list AnunnakiKungFu 2 305 Feb-27-2021, 12:10 AM
Last Post: BashBedlam
  Generate Random operator, take user input and validate the user mapypy 4 341 Feb-03-2021, 08:41 PM
Last Post: nilamo
  Loop back through loop based on user input, keeping previous changes loop made? hbkpancakes 2 507 Nov-21-2020, 02:35 AM
Last Post: hbkpancakes
  user input for multi-dimentional list without a prior iteration using input() Parshaw 6 678 Sep-22-2020, 04:46 PM
Last Post: Parshaw
  How to time a user's input Tbot1000 2 604 Aug-31-2020, 09:39 PM
Last Post: Larz60+
  converting user input to float troubles RecklessTechGuy 3 660 Aug-17-2020, 12:41 PM
Last Post: deanhystad
  Hi, I need help with defining user's input and applying it to code. jlmorenoc 2 660 Jun-24-2020, 02:10 PM
Last Post: pyzyx3qwerty
  if the input is not number, let user input again teatea 14 1,473 Jun-02-2020, 07:03 PM
Last Post: ibutun

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020