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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!