def ask_int(question, min_val=0, max_val=None, def_val=None):
    """ prompt user for a int value, keep asking until a correct value is entered"""
    val = ''
    while True:
        try:
            val = input(question)
            if not val and def_val is not None:
                val = def_val
                break
            if int(val) < min_val or max_val is not None and int(val
                ) > max_val:
                raise ValueError('')
            break
        except ValueError:
            if max_val is not None:
                print('sorry boss, choose something between %d and %d' % (
                    min_val, max_val))
            else:
                print('sorry boss, chose a number greater than %d' % min_val)
    return val
