''' Write a recommender function in Python, the input arguments are a list of string represents user preferred keywords and a list of articles with their own keywords, the output is the articles sorted by the relevance to the user preferred keywords. ''' def recommend(user_keywords, articles): # Calculate relevance scores for each article based on user's preferred keywords scores = [] for article in articles: common_keywords = set(article["keywords"]).intersection(user_keywords) score = len(common_keywords) / len(user_keywords) scores.append((article, score)) # Sort articles by relevance score sorted_articles = sorted(scores, key=lambda x: x[1], reverse=True) # Return list of articles in descending order of relevance return [article[0] for article in sorted_articles]