def yn_choice(message, default='y', tries=None):
    """asks for a yes/no question.

    :param tries: the number of tries
    :param message: the message containing the question
    :param default: the default answer
    """
    choices = 'Y/n' if default.lower() in ('y', 'yes') else 'y/N'
    if tries is None:
        choice = input('%s (%s) ' % (message, choices))
        values = ('y', 'yes', '') if default == 'y' else ('y', 'yes')
        return True if choice.strip().lower() in values else False
    else:
        while tries > 0:
            choice = input('%s (%s) (%s)' % (message, choices,
                "'q' to discard"))
            choice = choice.strip().lower()
            if choice in ['y', 'yes']:
                return True
            elif choice in ['n', 'no', 'q']:
                return False
            else:
                print('Invalid input...')
                tries -= 1
