Ocelot - Cindy T#14
Conversation
| def create_movie(title, genre, rating): | ||
| pass | ||
| movie = {} | ||
| if title and genre and rating: |
There was a problem hiding this comment.
Good use of "truthiness" to catch both "" and None in your validation tests :)
| add_to_watched(user_data, movie) | ||
| print(movie) | ||
| i = 0 | ||
| while i < len(user_data["watchlist"]): |
There was a problem hiding this comment.
I'm actually not quite sure that I am following how this is working :) It's a clever set up, but.. 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.
| genre_dict[genre] += 1 | ||
| for k, v in genre_dict.items(): | ||
| if v > high_genre: | ||
| high_genre = v |
There was a problem hiding this comment.
These variables names were a little confusing, as I read them myself, because they look similar. Could something like "highest_valued_genre", "highest_valued_genre_name" be more clear?
| return None | ||
| else: | ||
| #loop through genre in user_data | ||
| for movie in user_data["watched"]: |
There was a problem hiding this comment.
Nice use of a dict in your data processing implementation here
| user_movies = [] | ||
| friend_movies = [] | ||
|
|
||
| for friend in user_data["friends"]: |
There was a problem hiding this comment.
Could sets be helpful as a way to simplify some of this code?
No description provided.