def _parse_options(options):
    """Returns a Response after validating the input.
    """
    if options[1] in SORT_TYPES.keys():
        sort_type = options[1]
        if len(options) > 2:
            subreddit, sort_type, num_results = options
            try:
                num_results = int(num_results)
                return fetch_posts(subreddit, sort_type, num_results)
            except __HOLE__:
                # Third option is invalid.
                response_text = ("Sorry! `%s` isn't a valid sorting number. Try `/reddit %s %s 5`"
                                 % (subreddit, sort_type, num_results))
                return _create_response(response_text)
        else:
            # No option for results to return.
            return fetch_posts(options[0], sort_type)
    else:
        if isinstance(options[1], int):
            # For the case that someone passes `/reddit [subreddit] [sort_num]`
            return fetch_posts(options[0], 'hot', options[1])
        else:
            return _create_response('Invalid search. Try `/reddit aww top 5` or `/reddit help`.')
dataset/ETHPy150Open arjunblj/slack-reddit/app.py/_parse_options