Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Moving Objects Databases

Authors: Ralf Hartmut Güting, Markus Schneider

1st Edition

0120887991, 978-0120887996

More Books

Students also viewed these Databases questions