def getInt(prompt, limit=(0, None)):
while True:
try:
x = int(input(prompt))
if limit[0] is not None and x < limit[0]:
continue
if limit[1] is not None and limit[1] < x:
continue
return x
except:
pass
def setlimits():
lb = getInt('Please enter a Low bound: ', (1, None))
hb = getInt('Please enter a High bound: ', (lb, 9999))
return (lb, hb)
lb, hb = setlimits()
num = getInt('Please enter a number between %d and %d' % (lb, hb),
limit=(lb, hb))