← 返回 meta 的题目列表Mapping Movies to Categories and Ranking
类型:online_judge
meta
Given a list of movies and their respective categories, write a Python program to map movies to their categories and return the top 3 movies per category based on ratings. The input data consists of movie information (name, category, rating), and the output should be a dictionary with categories as keys and a list of the top-rated 3 movies as values. Assume each category has sufficient movies.
Example
Input
[('Movie1', 'Action', 8.5), ('Movie2', 'Drama', 9.0), ('Movie3', 'Action', 7.5)]