Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python program using input validation loop Practice input validation loop. Write a function, named menu, to display a menu of three choices and prompt the

image text in transcribed

python program using input validation loop

Practice input validation loop. Write a function, named menu, to display a menu of three choices and prompt the user to enter 1 or z or 3 for selecting item number 1 or 2 or 3, respectively. If the user's input is Invalid, you should display an error message and then prompt the user to enter again. In other words, there should be an input validation loop in the menu function, for repetitively prompting for a choice until the entered is a valid number which the menu function will return. With the execution of the following main function def main): userChoice menu ) print ) if userChoice1: print ('You chose option 1') elif userChoice2: print ('You chose option 2') else: print ('You chose option 3') an example interactive session is illustrated as below where users' inputs are underlined: Please enter your option (1, 2, or 3) >0 Invalid input, please try again Please enter your option (1, 2, or 3)->4 Invalid input, please try again Please enter your option (1, 2, or 3)->2 You chose option 2

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

ISBN: 1285427106, 978-1285427102

More Books

Students also viewed these Databases questions