Conversation
… the streaming services the user has
… genre and also completed the 3rd test
goeunpark
left a comment
There was a problem hiding this comment.
Wonderful work, Devin! 🎉
I actually do want to print and frame your commit messages because they are the gold standard! ⭐ Your code also shines; I can tell that you understand nested loops, conditionals, testing and modifying lists. This project is a well-deserved Green. 🟢
Keep up the great work! 🎉
| assert updated_data["watched"][0]["title"] == MOVIE_TITLE_1 | ||
| assert updated_data["watched"][0]["genre"] == GENRE_1 | ||
| assert updated_data["watched"][0]["rating"] == RATING_1 |
|
|
||
|
|
||
|
|
||
|
|
There was a problem hiding this comment.
Small nit: remove all the unnecessary whitespace before submitting! 😉
| movie = None | ||
| if title == None or genre == None or rating == None: | ||
| movie == None | ||
| else: | ||
| movie = { | ||
| "title" : title, | ||
| "genre" : genre, | ||
| "rating" : rating | ||
| } | ||
| return movie |
There was a problem hiding this comment.
On L12, we check if movie is None, not reassigning movie as None. We can also get rid of the temporary variable and return directly inside the else loop, like so:
if title == None or genre == None or rating == None:
return None
else:
return = {
"title": title,
"genre": genre,
"rating": rating
}
| def watch_movie(user_data, title): | ||
| for movie in user_data["watchlist"]: | ||
| if title in movie["title"]: | ||
| user_data["watchlist"].remove(movie) |
There was a problem hiding this comment.
One danger of modifying the user_data while iterating is that it could cause an error in our loop. Try to avoid modifying a list while you're iterating through it!
| counter = 0 | ||
| average = 0.0 | ||
| for movie in user_data["watched"]: | ||
| if movie["rating"] == False: |
There was a problem hiding this comment.
A more pythonic way to write this code is:
if not movie["rating"]:
| # ------------- WAVE 4 -------------------- | ||
| # ----------------------------------------- | ||
| def get_available_recs(user_data): | ||
| unwatched_movies = get_friends_unique_watched(user_data) |
There was a problem hiding this comment.
Nice job using get_friends_unique_watched()! 🎉
| for movie in unwatched_movies: | ||
| if movie["host"] in user_data["subscriptions"]: | ||
| movie_recs.append(movie) |
There was a problem hiding this comment.
I feel like you can do this in your sleep now! 😴
| # ------------- WAVE 5 -------------------- | ||
| # ----------------------------------------- | ||
| def get_new_rec_by_genre(user_data): | ||
| unwatched_movies = get_friends_unique_watched(user_data) |
| unwatched_movies = get_friends_unique_watched(user_data) | ||
| movie_recs = [] | ||
| for movie in unwatched_movies: | ||
| if movie["genre"] == get_most_watched_genre(user_data): |
| for movie in user_data["favorites"]: | ||
| if movie in unwatched_movies: | ||
| movie_recs.append(movie) | ||
| return movie_recs No newline at end of file |
There was a problem hiding this comment.
Python likes a newline at the end of the file, otherwise Github shows a silly 🚫
No description provided.