validate_user_str#

pybear.base.validate_user_str(user_prompt, options)#

Validation of a single user-entered alpha character against a list of allowed characters. Not case sensitive.

Parameters:
user_promptstr

Text string displayed to the user at prompt.

optionsstr

A single text string containing the allowed characters.

Returns:
user_inputstr

Validated user selection.

Examples

>>> from pybear.input_validation import validate_user_str
>>> out = validate_user_str('Enter selection > ', 'ABC')
Enter Selection > f
>>> # prompts again because of invalid selection (not a given option)
Enter Selection > a
>>> out
A