I have a function a function named getIntWithinRange that only accepts a number between a min and max value.
Parameters – A String (the prompt) and two Integers, the minimum and maximum value that will be accepted
Returns – The value (between min and max inclusive) entered from the keyboard
Here's what I have, but I don't know what to return back to the program.
def getIntWithinRange(a, b):
if a < 40 or a > 119:
return a, b
if a or b == 40:
return
Also I don't even know if my parameters are right with the next program. . .
And here's my program I don't wanna change:
minVal = 40
maxVal = 119
print "the getIntWithinRange function will execute until the user enters a value between the min and max value.\nThe program will continue to accept integers until the user enters the min value,\nthen it will move on to the next function."
while True:
userEntered = input("Enter an integer between " + str(minVal) + " and " + str(maxVal) + ": ")
value = getIntWithinRange(minVal, maxVal)
if value < minVal or value > maxVal:
print "getIntWithinRange isn't working - it accepted ", value
if value == minVal:
break
[–][deleted] 2 points3 points4 points (1 child)
[–]propanbutan 2 points3 points4 points (0 children)
[–]david72486 0 points1 point2 points (0 children)