Need help to code a program which:
- validate user input, accept values that a user has entered (ex, a, b, c, d, e)
- any other values other than these are to be treated invalid with a message and block it from processing.
- Prompt the user to enter the values again.
- The code should do this until a valid value has been entered.
- once a valid value has been entered it is to continue processing.

I have posted one example of my coding here:
http://www.daniweb.com/forums/post1188875.html#post1188875

You can make simpler version of this based on your input, this code is for more complicated case of number values from string.

if x in 'abc':

or

if x not in 'abc':

Might be handy for validating letters.

Need help to code a program which:
- validate user input, accept values that a user has entered (ex, a, b, c, d, e)
- any other values other than these are to be treated invalid with a message and block it from processing.
- Prompt the user to enter the values again.
- The code should do this until a valid value has been entered.
- once a valid value has been entered it is to continue processing.

On homework problems like that we do request some coding effort on your part.

for this type of programme a while loop would be best. have a method to display whatever and accept input and return into the while where you can validate it. If the input is valid process whatever and break the loop else display error message have the user to press enter and go back to the display method.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.