def get_input(prompt, operation, check=None):
    """
    Prompt the user for input and apply ``operation`` to input.
    If ``check`` is not None run the check on the converted input

    If value is invalid it will re-prompt user
    """
    while 1:
        try:
            value = input(prompt)
            value = operation(value)
            if check:
                if not check(value):
                    raise Exception
            return value
        except (ValueError, Exception):
            continue