how to clamp an integer to some range? (in python),"new_index = max(0, min(new_index, len(mylist) - 1))"