Question: 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

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!