def display_result(): # Stores list of articles returned from searching user's keyword articles = search(ask_search()) # advanced stores user's chosen advanced option (1-5) # value stores user's response in being asked the advanced option advanced, value = ask_advanced_search() if advanced == 1: # value stores max article title length in number of characters # Update article metadata to contain only ones of the maximum length # TODO uncomment following line after writing the function and delete pass articles = article_length(value, articles) if advanced == 2: # value stores max number of articles # Update article metadata to contain only the max number of articles # TODO uncomment following line after writing the function and delete pass articles = article_count(value, articles) elif advanced == 3: # value stores random number # Update articles to only contain article metadata at index of random number # TODO uncomment following line after writing the function and delete pass articles = random_article(value, articles) elif advanced == 4: # value stores author # Store whether author is in search results into variable named has_favorite # TODO uncomment following line after writing the function and delete pass has_favorite = favorite_author(value, articles) elif advanced == 5: # Update article metadata to only contain titles and authors # TODO uncomment following line after writing the function and delete pass articles = title_author(articles) elif advanced == 6: # value stores keyword to search # Update article metadata to contain article metadata from both searches # TODO uncomment following line after writing the function and delete pass articles = multiple_keywords(value, articles) print() if not articles: print("No articles found") else: print("Here are your articles: " + str(articles)) if advanced == 4: print("Your favorite author is" + ("" if has_favorite else " not") + " in the returned articles!")
def display_result(): # Stores list of articles returned from searching user's keyword articles = search(ask_search(), keyword_to_titles_map()) # advanced stores user's chosen advanced option (1-7) # value stores user's response in being asked the advanced option advanced, value = ask_advanced_search() if advanced == 1: # Update articles to contain metadata # TODO uncomment following line after writing the function and delete pass articles = article_info(articles, title_to_info_map()) if advanced == 2: # value stores max length of articles # Update articles to contain only ones not exceeding the maximum length # TODO uncomment following line after writing the function and delete pass articles = article_length(value, articles, title_to_info_map()) elif advanced == 3: # Update article metadata to only contain titles and timestamps # TODO uncomment following line after writing the function and delete pass articles = title_timestamp(articles, title_to_info_map()) elif advanced == 4: # Store whether author wrote an article in search results into variable # named has_favorite # TODO uncomment following line after writing the function and delete pass has_favorite = favorite_author(value, articles, title_to_info_map()) elif advanced == 5: # value stores keyword to search # Update article metadata to contain article metadata from both searches # TODO uncomment following line after writing the function and delete pass articles = multiple_keywords(value, articles) print() if not articles: print("No articles found") else: print("Here are your articles: " + str(articles)) if advanced == 4: print("Your favorite author is" + ("" if has_favorite else " not") + " in the returned articles!")