Question: This is for an intro to python class using Python 3: Write a program with a function called retrieve_integer. This function should ask the user

This is for an intro to python class using Python 3:

Write a program with a function called retrieve_integer. This function should ask the user for a number. If they enter a non-integer, your function should print "Uh oh!". However, the exception should not stop there; it should continue to wherever your function was called! (Consider using the word raise by itself here.)

use this at the end of your program:

try:

print(retrieve_integer())

except ValueError:

print('ValueError caught!')

Sample Input:

abc

Sample Output:

Enter number: Uh oh!

ValueError caught!

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 Databases Questions!