Skip to content
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

Ocelots - Megan Maple #2

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

maple-megan333
Copy link

No description provided.

# *******************************************************************************************
# ****** Add assertions here to test that the correct movie was added to "watched" **********
# *******************************************************************************************
assert updated_data["watched"][0]["title"] == MOVIE_TITLE_1

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

Nice job testing the specific content here

@@ -1,23 +1,123 @@
# ------------- WAVE 1 --------------------

def create_movie(title, genre, rating):
pass
print("***************************")
new_movie = {

Choose a reason for hiding this comment

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

There was room for input validation here :)

Choose a reason for hiding this comment

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

-- 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"]:

Choose a reason for hiding this comment

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

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)

Choose a reason for hiding this comment

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

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 = {

Choose a reason for hiding this comment

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

Good use of a dict in your data processing


# -----------------------------------------
# ------------- WAVE 3 --------------------
# -----------------------------------------

def get_unique_watched(user_data):

Choose a reason for hiding this comment

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

Could sets have been useful alternatives to the nested loops in these functions?

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