def input_int(prompt, default=None, minimum=None, maximum=None):
    """
    ask the user to enter an integer number
    make sure it's an integer, and within possibly given criteria
    default: default value (if the user leaves it empty)
             if default is None, user can not leave it empty
    minimum: minimum allowed value, or None
    maximum: maximum allowed value, or None
    """
    while True:
        value_str = input(prompt).strip()
        if not value_str:
            if default is None:
                print('Can not leave empty')
                continue
            else:
                return default
        try:
            value = int(value_str)
        except ValueError:
            print('Must enter an integer number')
            continue

        if minimum is not None and value < minimum:
            print('Must enter greater than or equal to %s' % minimum)
            continue

        if maximum is not None and value > maximum:
            print('Must enter less than or equal to %s' % maximum)
            continue

        return value