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
  Loop back through loop based on user input, keeping previous changes loop made? hbkpancakes 2 136 Nov-21-2020, 02:35 AM
Last Post: hbkpancakes
  user input for multi-dimentional list without a prior iteration using input() Parshaw 6 351 Sep-22-2020, 04:46 PM
Last Post: Parshaw
  How to time a user's input Tbot1000 2 278 Aug-31-2020, 09:39 PM
Last Post: Larz60+
  converting user input to float troubles RecklessTechGuy 3 396 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 453 Jun-24-2020, 02:10 PM
Last Post: pyzyx3qwerty
  if the input is not number, let user input again teatea 14 966 Jun-02-2020, 07:03 PM
Last Post: ibutun
  How to allow user input only if certain requirements are met vininhosts 3 457 May-28-2020, 06:15 PM
Last Post: micseydel
  Python - Most effective way to correct keyboard-user-input. ppel123 8 691 Apr-08-2020, 07:41 AM
Last Post: ppel123
  User input & Dictionary tfernandes 5 694 Apr-03-2020, 07:12 PM
Last Post: tfernandes
  User Input and CSV File Davy_Jones_XIV 2 882 Mar-24-2020, 08:43 AM
Last Post: Davy_Jones_XIV

Forum Jump:

User Panel Messages

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