Conversation
| for movie in user_data["watchlist"]: | ||
| if movie["title"] == title: | ||
| watched_dict = movie | ||
| break | ||
| else: | ||
| return user_data | ||
| user_data["watched"].append(watched_dict) | ||
| user_data["watchlist"].remove(watched_dict) | ||
|
|
||
| return user_data |
There was a problem hiding this comment.
This works, but the flow is a little awkward. I would recommend restructuring for readability:
| for movie in user_data["watchlist"]: | |
| if movie["title"] == title: | |
| watched_dict = movie | |
| break | |
| else: | |
| return user_data | |
| user_data["watched"].append(watched_dict) | |
| user_data["watchlist"].remove(watched_dict) | |
| return user_data | |
| for movie in user_data["watchlist"]: | |
| if movie["title"] == title: | |
| watched_dict = movie | |
| user_data["watched"].append(watched_dict) | |
| user_data["watchlist"].remove(watched_dict) | |
| return user_data |
| for movie in user_data["watched"]: | ||
| user_rating.append(movie["rating"]) | ||
|
|
||
| average = sum(user_rating)/len(user_rating) |
There was a problem hiding this comment.
Nice solution! As above, this works, but the layout implies different logic than what is actually here. I would recommend eliminating the else and moving lines 49-51 to the same tab level as this line.
| for movie in user_data["watched"]: | ||
| most_watched.append(movie["genre"]) | ||
|
|
||
| return max(most_watched, key = most_watched.count) |
There was a problem hiding this comment.
How would you solve this without using the max function?
| #Wave 3 Tests 1 2 | ||
| def get_unique_watched(user_data): | ||
|
|
||
| #Creating variables that are not exactly necessary but make my code easier to read (at least to me) |
There was a problem hiding this comment.
👍 Helper variables are a great way to improve readability!
| friends_movies_first = friends_movies[0] | ||
| friends_movies_second = friends_movies[1] | ||
| # adding each item(dictionary) to friends_movies_list | ||
| for dictionary in friends_movies_first["watched"]: | ||
| friends_movies_list.append(dictionary) | ||
|
|
||
| for dictionary in friends_movies_second["watched"]: | ||
| friends_movies_list.append(dictionary) |
There was a problem hiding this comment.
There is a logical bug in this section. This only handles the first two friends in the friends list - what happens if there are more? Note - your code in get_unique_watched on lines 77-79 does similar work without the bug.
|
|
||
| for movie in user_movies: | ||
| for item in unique_friends_list: | ||
| if movie["title"] in item.values(): |
There was a problem hiding this comment.
There is a logical bug on this line. What if there is a movie with the title "Intrigue", and a movie in the friends list has a title and a genre, and the genre is "Intrigue"? This conditional will be true, and that movie will be removed from unique_friends_list even though the titles don't match. How could you compare just the titles?
| # Wave 4 Tests 1 2 3 4 | ||
| def get_available_recs(user_data): | ||
|
|
||
| recommendations = get_friends_unique_watched(user_data) |
|
|
||
| recommendations = get_friends_unique_watched(user_data) | ||
|
|
||
| for movie in range(len(recommendations)): |
There was a problem hiding this comment.
This outer loop is not doing anything.
| #removes duplicates | ||
| rec_movies = [i for n, i in enumerate(rec_movies) if i not in rec_movies[n + 1:]] | ||
|
|
||
| return rec_movies |
There was a problem hiding this comment.
There is a logical bug in this function. This function does not check for the most popular genre or do any checking against the genre. It will produce the same output as 'get_friends_unique_watched'.
| for movie in user_favorites: | ||
| if movie not in friends_list: | ||
| favorites.append(movie) | ||
|
|
||
| return favorites No newline at end of file |
No description provided.