Conversation
|
|
||
| def create_movie(title, genre, rating): | ||
| pass | ||
| if title and genre and rating: |
There was a problem hiding this comment.
Interesting use of python "Truthyness" to validate for "" or None
| def watch_movie(user_data, title): | ||
| movie_watchlist = user_data["watchlist"] | ||
| # TODO: Should we check if the movie has already been watched? | ||
| for index, movie in enumerate(movie_watchlist): |
There was a problem hiding this comment.
interesting way to loop, using enumerate to get an index!
There was a problem hiding this comment.
In general, it's considered dangerous practice to modify the content of a data structure that your looping over. This can lead to bugs in more complex code. One alternative could be to find another way without using specific indices, for example, just keeping a copy of a list of movies in movie_watchlist and looping over those. That way, inside that loop, modifying movie_watchlist would be perfectly safe.
| most_watched_genre = None | ||
| max_amount = 0 | ||
| for genre, times in genre_map.items(): | ||
| # if there is a tie, keep the first |
There was a problem hiding this comment.
Great comment, making it clear that you thought out the tie case
| # ----------------------------------------- | ||
|
|
||
| # return a dictionary, key is title, value is a dictionary of movie's information | ||
| def get_friends_watched_movies(friends): |
There was a problem hiding this comment.
Good implementation. For this and similar functions, could you think about using sets to simplify some of this code?
| def get_friends_unique_watched(user_data): | ||
| friends = user_data["friends"] | ||
| watched_movies = user_data["watched"] | ||
| user_watched = set() |
There was a problem hiding this comment.
was there a specific reason that a set was used here?
Solve viewing party assignment.