-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Panthers - Stevie L. #170
base: master
Are you sure you want to change the base?
Panthers - Stevie L. #170
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job using the suggested refactoring! 🎉
def watch_movie(user_data, title): | ||
user_data_copy = user_data.copy() | ||
|
||
title_list = [dicts["title"] for dicts in user_data["watchlist"]] | ||
title_list.extend(dicts["title"] for dicts in user_data["watched"]) | ||
|
||
if title not in title_list: | ||
return user_data | ||
user_data_copy["watched"].append(user_data_copy["watchlist"].copy()) | ||
user_data_copy["watchlist"].pop() | ||
|
||
return user_data_copy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can simplify this by doing something like this:
def watch_movie(user_data, title):
for movie in user_data["watchlist"]:
if movie["title"] == title:
user_data["watchlist"].remove(movie)
user_data["watched"].append(movie)
return user_data
# ----------------------------------------- | ||
# ------------- WAVE 2 -------------------- | ||
# ----------------------------------------- | ||
def get_watched_avg_rating(user_data): | ||
watched_list = get_watched_list(user_data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work using your previous function!
def get_watched_list(user_data): | ||
return user_data['watched'] | ||
|
||
def get_friends_watched_list(user_data): | ||
friends_list = user_data['friends'] | ||
|
||
friends_watch_list = [dicts['watched'] for dicts in friends_list] | ||
friends_watch_list = [val for sublist in friends_watch_list for val in sublist] | ||
|
||
return list({movie['title']:movie for movie in friends_watch_list}.values()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work creating helper functions!
watched_list = get_watched_list(user_data) | ||
genre_list = [movie['genre'] for movie in watched_list] | ||
|
||
return max(genre_list, key = genre_list.count) if genre_list else None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯💯
watched_list = get_watched_list(user_data) | ||
friends_list = get_friends_watched_list(user_data) | ||
|
||
for movie in watched_list: | ||
if movie in friends_list: | ||
friends_list.remove(movie) | ||
|
||
return friends_list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing work! 😁
refactored party.py for list comprehension and readability