Skip to content

Panthers - Stevie L.#170

Open
lopezsteffanie wants to merge 13 commits intoAda-C18:masterfrom
lopezsteffanie:master
Open

Panthers - Stevie L.#170
lopezsteffanie wants to merge 13 commits intoAda-C18:masterfrom
lopezsteffanie:master

Conversation

@lopezsteffanie
Copy link
Copy Markdown

refactored party.py for list comprehension and readability

Copy link
Copy Markdown

@ameerrah9 ameerrah9 left a 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! 🎉

Comment thread viewing_party/party.py
Comment on lines +36 to +47
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
Copy link
Copy Markdown

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

Comment thread viewing_party/party.py
# ------------- WAVE 2 --------------------
# -----------------------------------------
def get_watched_avg_rating(user_data):
watched_list = get_watched_list(user_data)
Copy link
Copy Markdown

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!

Comment thread viewing_party/party.py
Comment on lines +4 to +13
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())
Copy link
Copy Markdown

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!

Comment thread viewing_party/party.py
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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯💯

Comment thread viewing_party/party.py
Comment on lines +80 to +87
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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work! 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants