Answered step by step
Verified Expert Solution
Question
1 Approved Answer
HELP! 1. Write a function that takes an integer val as an argument and asks user to enter a guess number. -If the number is
HELP!
1. Write a function that takes an integer val as an argument and asks user to enter a guess number.
-If the number is greater than val, the function displays Too high and prompt again for a number
-If the number is less than val, the function displays Too low and prompt again for a number
-If the number equals val, the function displays Got it! and ends.
-Call the function repeatedly until the user enters the right number.
My code: It runs into and endless loop of either "Too high" or "Too low". What is wrong with my code?
GNU nano 2.5.3 # ! /usr/bin/pythons import randonm def guessValue (val) nint (input ("Enter the number ")) while n-=val: if n val: print ("Too high") else: print "Too low") print ("Got it! val -random.randint l,100) guessValue (val)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started