Question
using Python: Write a function named safe input(prompt,type) that works likethe Python input function, except that it only accepts thespecified type of input. The function
using Python:
Write a function named safe input(prompt,type) that works likethe Python input function, except that it only accepts thespecified type of input. The function takes two arguments:
r prompt: str
r type: int, float, str
The function will keep prompting for input until correct input ofthe specified type is entered.
The function returns the input. If the input was specified to be anumber ( float or int), the value returned will be of the correcttype; that is, the function will perform the conversion.
The default for a prompt is the empty string. The default for thetype is string.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started