Open
Conversation
…ffecting wave 4 output
tgoslee
reviewed
Sep 21, 2021
Comment on lines
+2
to
+10
| def create_movie(title, genre, rating): | ||
| if title and genre and rating: | ||
| movie_dict = {} | ||
| movie_dict["title"] = title | ||
| movie_dict["genre"] = genre | ||
| movie_dict["rating"] = rating | ||
| return movie_dict | ||
| else: | ||
| return None |
There was a problem hiding this comment.
This works great but you could just return the title. genre, and rating without doing movie_dict = {}
Suggested change
| def create_movie(title, genre, rating): | |
| if title and genre and rating: | |
| movie_dict = {} | |
| movie_dict["title"] = title | |
| movie_dict["genre"] = genre | |
| movie_dict["rating"] = rating | |
| return movie_dict | |
| else: | |
| return None | |
| def create_movie(movie_title, genre, rating): | |
| if movie_title == None or genre == None or rating == None: | |
| return None | |
| else: | |
| return { | |
| "title":title, | |
| "genre":genre, | |
| "rating":rating | |
| }``` |
tgoslee
reviewed
Sep 21, 2021
| return None | ||
|
|
||
| def add_to_watched(user_data, movie): | ||
| if "watched" in user_data.keys(): |
There was a problem hiding this comment.
great check to see if watched is a key in user_data
tgoslee
reviewed
Sep 21, 2021
|
|
||
| return user_data | ||
|
|
||
| def add_to_watchlist(user_data, movie): |
tgoslee
reviewed
Sep 21, 2021
| count += 1 | ||
| if item["title"] == title: | ||
| watched_movie = user_data["watchlist"][count-1] | ||
| user_data["watchlist"].remove(watched_movie) |
There was a problem hiding this comment.
even though remove works great here, be careful using it in a for loop. It can cause side effects. Here is a link that explains it more with examples https://thispointer.com/python-remove-elements-from-a-list-while-iterating/
tgoslee
reviewed
Sep 21, 2021
| return user_data | ||
|
|
||
| # WAVE 2 # | ||
| def get_watched_avg_rating(user_data): |
tgoslee
reviewed
Sep 21, 2021
| # use 'max' function to return highest value | ||
| # .get() is used to get the value | ||
| most_frequent = str(max(frequency_dict, key=frequency_dict.get)) | ||
| except ValueError: |
tgoslee
reviewed
Sep 21, 2021
| return most_frequent | ||
|
|
||
| # WAVE 3 # | ||
| def get_unique_watched(user_data): |
tgoslee
reviewed
Sep 21, 2021
|
|
||
| return unique_user_list | ||
|
|
||
| def get_friends_unique_watched(user_data): |
tgoslee
reviewed
Sep 21, 2021
|
|
||
| # WAVE 4 # | ||
| def get_available_recs(user_data): | ||
| unique_friend_list = get_friends_unique_watched(user_data) |
tgoslee
reviewed
Sep 21, 2021
Comment on lines
+156
to
+158
| fav_genre = get_most_watched_genre(user_data) | ||
| # returns fav genre, which is a string | ||
| unique_friends_watched = get_friends_unique_watched(user_data) |
tgoslee
reviewed
Sep 21, 2021
|
|
||
| return new_rec | ||
|
|
||
| def get_rec_from_favorites(user_data): |
|
Great job. I added some comments on refactoring code, use of helper functions, and using the remove method. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.