def checkrange(value, lo, hi, msg=''):
    """Check value for membership; raise ValueError if fails."""
    if value < lo or value > hi:
        raise ValueError(f'ERROR {msg}: {value} should be in range {lo} {hi}')
