C-17 Otters - Marlyn Lopez#114
Conversation
kendallatada
left a comment
There was a problem hiding this comment.
Hi Marlyn! Your submission has been scored as green. Please check your code to see the comments I left. Let me know if you have any questions. Nice work! :)
|
|
||
| def create_movie(title, genre, rating): | ||
| pass | ||
| result = None |
There was a problem hiding this comment.
This variable isn't being used. Moving forward, be sure to check your code for unnecessary work. :)
| def create_movie(title, genre, rating): | ||
| pass | ||
| result = None | ||
| if not title or not genre or not rating: |
| result = None | ||
| if not title or not genre or not rating: | ||
| return None | ||
| movie = {} |
There was a problem hiding this comment.
Small suggestion to cut down on lines of code - rather than creating the dictionary in steps, you could do it all in one step like this:
movie = {"title": title, "genre": genre, "rating": rating}
or even just returning it without creating a variable:
return {"title": title, "genre": genre, "rating": rating}
|
|
||
|
|
||
| def watch_movie(user_data, title): | ||
| for key in user_data["watchlist"]: |
There was a problem hiding this comment.
Consider using a more descriptive variable name for key. Also, pay attention to how many times your loop will iterate and when it exits. Right now, your loop will keep going until it reaches the end of watchlist even if it already found the title. This is a suuuuper easy mistake to make. Now, that we have chatted about Big O, pay attention to if your code is doing unnecessary work.
| assert len(updated_data["watched"]) is 2 | ||
| assert len(updated_data["watchlist"]) == 1 | ||
| assert len(updated_data["watched"]) == 2 | ||
| # assert updated_data["watched"][0]["title"] == MOVIE_TITLE_1 |
|
|
||
|
|
||
|
|
||
| def friends_movies(user_data): |
There was a problem hiding this comment.
Love that you're creating helper functions ❤️
| friends_movie_titles.append(movie) | ||
| return friends_movie_titles | ||
|
|
||
| def get_friends_unique_watched(user_data): |
There was a problem hiding this comment.
This is also a great solution! I would challenge you to see if you can get this solution down to 2 for loops as well.
|
|
||
| def get_available_recs(user_data): | ||
| recommendations = [] | ||
| for movie in get_friends_unique_watched(user_data): |
There was a problem hiding this comment.
Loooove that you're taking advantage of functions you have already written. ❤️ Now that we have talked about Big O, think about how the efficiency of the helper function impacts the time complexity of the overall solution. Is the helper function doing work that is unnecessary for this solution? Think about how you could refactor your code so it does less work.
| # ------------- WAVE 5 -------------------- | ||
| # ----------------------------------------- | ||
|
|
||
| def get_new_rec_by_genre(user_data): |
|
|
||
| def get_rec_from_favorites(user_data): | ||
| favorites_recommendation = [] | ||
| new_movie = get_unique_watched(user_data) |
There was a problem hiding this comment.
This is a super clean solution! I would challenge you to think about how you can refactor this code to improve the time complexity. Consider if it would be faster to not use the get_unique_watched() function.
No description provided.