def compile_ratings(movie_id): result = api.get_reviews(movie_id) output = [] for res in result['reviews']: try: data = [sanitize(res['original_score']), res['quote']] output.append(data) except KeyError: pass return list(filter(lambda x: x[0] != None, output))