Use Python to solve this coding problem

3. Top Articles Query a REST API to get information about a list of articles. Given an integer, limit, return the top limit article names ordered decreasing by comment count, then increasing alphabetically for those that have the same comment counts. To access the collection of users perform HTTP GET request to:<pageNumber> where <pageNumber $>$ is an integer denoting the page of the results to return and 1 $<=$ pageNumber <= total_pages. For example, GET request to: will return the second page of the collection of articles. The response is a JSON object with the following 5 fields: - page: The current page of the results - per_page: The maximum number of records returned per page. - total: The total number of records on all pages of the result. - total_pages: The total number of pages with results. - data: An array of objects containing records returned on the requested page Each data record has the following schema: - title: The title of the article. Can be null - url: the URL of the article

- num_comments: the number of comments the article has. Can be null. If it is null, the article has no comments, which means it has 0 comments. - story_id: identifier of the story related to the article. Can be null - story_title: the title of the story related to the article. Can be null - story_url: the URL of the story related to the article. Can be null - parent_id: identifier of the parent of the article. Can be null - created_at: the date and time when the record was created First get the article name. - If the title field is not null, use title. - Otherwise, if the story_title field is not null, use story_title. - If both fields are null, ignore the article. Sort the titles decreasing by comment count, then increasing alphabetically by article name if there is a tie in comments count. Return a list of the top limit names. Function Description Complete the function topArticles in the editor below. topArticles has the following parameter(s): int limit: the number of articles to return Returns string[k]: the names of articles

Returns string $[k]$ : the names of articles Input Format For Custom Testing Sample Case 0 Sample Input For Custom Testing 2 Sample Output UK votes to leave EU F.C.C. Repeals Net Neutrality Rules Explanation The limit value is 2 so we are interested in the names of the first two articles with the most number of comments. Those top articles are: 1. title: F.C.C. Repeals Net Neutrality Rules, story_title: null, num_comments: 1397 2. title: UK votes to leave EU, story_title: null, num_comments: 2531 and their names are their titles because they are not null. The second of these articles have more comments, so, it comes the first in the order. Therefore, the first element of the answer is "UK votes to leave EU" and the second element is "F.C.C. Repeals Net Neutrality Rules".

$1>\# ! /$ bin/python3 $\cdots$ 10 $11 \#$ 12 \# Complete the 'topArticles' function below. $13 \quad \#$ 14 \# The function is expected to return a STRING_ARRAY. 15 \# The function accepts INTEGER limit as parameter. 16 \# base url for copy/paste: 17 \#<pageNumber $\rangle$ $18 \#$ 19 20 def topArticles(limit): 21 \# Write your code here 22

Public Answer

HWLGZG The First Answerer