Problem

Write a function named safe_input(prompt,type) that works like the Python input function,...

Write a function named safe_input(prompt,type) that works like the Python input function, except that it only accepts the specified type of input. The function takes two arguments:

• prompt: str• type: int, float, str

The function will keep prompting for input until correct input of the specified type is entered.

The function returns the input. If the input was specified to be a number (float or int), the value returned will be of the correct type; that is, the function will perform the conversion.

The default for a prompt is the empty string. The default for the type is string.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 5
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT