I need help with a python programming problem. the question is, modify the guess my number chapter project by reusing the function ask_number(). here is the guess my number programimport random
print("welcome")
print("number between 1-100")
print("guess")
the_number = random.randint(1, 100)
guess = int(input("take a g:"))
tries = 1
lose = 10
while guess != the_number and tries < lose:
if guess > the_number:
print("lower")
else:
print("higher")
guess =int(input("take a guess"))
tries += 1
if tries == lose:
print("You have exceeded your max number of attempts; therefore, you lose!")
else:
print("you guessed it! the number was", the_number)
print("and it only took you", tries, "tries!\n")
input("\n\nPress the enter key the exit.") here is the the ask_number function
def ask_number(question, low, high ):
"""Ask for a number within a range."""
response = None
while response not in range(low, high ):
response = int(input(question))
return response

Hey! We 've verified this expert answer for you, click below to unlock the details :)

I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!

Looking for something else?

Not the answer you are looking for? Search for more explanations.