Write a function named getBetween.
getBetween should take two arguments: low and high. getBetween should prompt the user for an integer between low and high, inclusive (in other words, greater than or equal to low and less than or equal to high). If the user enters a number that is not in the proper range, getBetween should tell the user that they made an error and ask them again. If the user enters something that is not a number, getBetween should detect this (by using exceptions), inform the user of their error, and ask them again. When the user enters an acceptable answer, return it.
So what I can't figure out how to do is to re-prompt the user if the input number is not in range. Here's my code:
while True:
try:
low = int(input("Enter a low number: "))
high = int(input("Enter a high number: "))
except ValueError:
print("Invalid Input")
continue
else:
break
var = false
def getBetween(low,high):
while True:
try:
number = int(input("Enter a number: "))
except ValueError:
print("Invalid Input")
continue
else:
break
if low<number<high:
print(number)
else:
print("This input is not in range.")
getBetween(low,high)