Conversation
| # ******************************************************************************************* | ||
| # ****** Add assertions here to test that the correct movie was added to "watched" ********** | ||
| # ******************************************************************************************* | ||
| assert updated_data["watched"][0]["title"] == MOVIE_TITLE_1 |
There was a problem hiding this comment.
Good job testing all of the attributes here :)
| # ************************************************************************************************* | ||
| # ****** Add assertions here to test that the correct movies are in friends_unique_movies ********** | ||
| # ************************************************************************************************** | ||
| assert INTRIGUE_3 in friends_unique_movies |
There was a problem hiding this comment.
Nice job testing the specific content here
| def create_movie(title, genre, rating): | ||
| pass | ||
| print("***************************") | ||
| new_movie = { |
There was a problem hiding this comment.
There was room for input validation here :)
There was a problem hiding this comment.
-- before the data structure was created and tested, below :)
| return user_data | ||
|
|
||
| def watch_movie(user_data, movie_title): | ||
| for movie in user_data["watchlist"]: |
There was a problem hiding this comment.
Note, while this may work here, it's considered dangerous practice to modify the content of a data structure that you're looping over. Especially in more complex code, this can open you up to complex errors. A simple alternative here could be to save a copy of what you get from movie in user_data["watchlist"] and iterate over that, so that as you modify user_data["watchlist"], there's no risk.
| movie_genres[movie['genre']] += 1 | ||
| else: | ||
| movie_genres[movie['genre']] = 1 | ||
| return max(movie_genres, key=movie_genres.get) |
There was a problem hiding this comment.
Nice use of max() with a custom key function to sort a dict!
|
|
||
| def get_most_watched_genre(user_data): | ||
| if user_data["watched"]: | ||
| movie_genres = { |
There was a problem hiding this comment.
Good use of a dict in your data processing
| # ------------- WAVE 3 -------------------- | ||
| # ----------------------------------------- | ||
|
|
||
| def get_unique_watched(user_data): |
There was a problem hiding this comment.
Could sets have been useful alternatives to the nested loops in these functions?
No description provided.