Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can anyone look into this function, am getting this error # The call get_bet(800) crashed on the following input: a, -200, 1000, 120.5, 100. Traceback

Can anyone look into this function, am getting this error #

The call get_bet(800) crashed on the following input: a, -200, 1000, 120.5, 100. Traceback (most recent call last): ValueError: invalid literal for int() with base 10: 'a' # code def get_bet(credits): """ Returns the number of credits bet by the user. This function asks the user to make a bet Make a bet: If bet is not an integer, it responds with the error message The bet must be an integer. If bet is 0 or less, it responds with the error message The bet must be a positive integer. Finally, if bet is more than credits, it responds with the error message You do not have enough credits for that bet. It continues to ask for a bet until the user gives a valid answer. Parameter credits: the number of credits available to bet Precondition: credits is an int > 0 """ loop_control = True bet = 0 while loop_control: bet = int(input('Make a bet: ')) if type(bet) != int: print('The bet must be an integer') elif bet < 0: print('The bet must be a positive integer') elif bet >= credits: print('You do not have enough credits for that bet') else: loop_control = False return bet 

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_2

Step: 3

blur-text-image_3

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

How To Make A Database In Historical Studies

Authors: Tiago Luis Gil

1st Edition

3030782409, 978-3030782405

More Books

Students also viewed these Databases questions

Question

How could assessment be used in an employee development program?

Answered: 1 week ago