def boundThis(x):
min = 20
max= 100
boundX = int(x)
if (boundX > max):
boundX = boundX % max + min-1
if (boundX > max):
boundX-=max-1
else:
while(boundX < min):
boundX += max-min
return boundX
I'm trying to bound x between two numbers, 20 and 100 (exclusive). That said, once it hits 100, it should loop back to 20.
I get how it works with the while loop, (while boundX < min) but am having trouble with the modulus operator and writing the correct expression with that.
Ex. boundThis(201) should give me like 21, and boundThis(100) giving me 20.