You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These functions are all really close to being correct! It performs all the operations and tests we need to determine the highest value in our dictionaries. However, we need to change just a couple of things: how we access values in a dictionary and how certain functions are called.
First, when trying to access a value in a dictionary, we need to change how we access it. Instead of writing self.books.values[book], we need to write self.books[books] to get the proper value.
P.S. values is actually a function that returns a list of all the values contained in the dictionary. For more information on dictionaries, please refer to the Codecademy lessons and/or this documentation: https://realpython.com/python-dicts/
The last thing we have to change is how we are calling the get_average_rating function. We need to change it from book.get_average_rating[book] to book.get_average_rating().
This change is necessary because get_average_rating is a function defined in our Book object. To call this function, we need to access that function from the Book object (e.g. book) and then pass it the necessary parameters. In this case, the function has no parameters, so we can simply call the function like so: book.get_average_rating().
If you have any further questions about calling class functions and/or class concepts, please refer back to the Codecademy lessons.
The text was updated successfully, but these errors were encountered:
pwp-capstones/TomeRater/TomeRater.py
Lines 137 to 164 in bde75d2
These functions are all really close to being correct! It performs all the operations and tests we need to determine the highest value in our dictionaries. However, we need to change just a couple of things: how we access values in a dictionary and how certain functions are called.
First, when trying to access a value in a dictionary, we need to change how we access it. Instead of writing
self.books.values[book]
, we need to writeself.books[books]
to get the proper value.P.S.
values
is actually a function that returns a list of all the values contained in the dictionary. For more information on dictionaries, please refer to the Codecademy lessons and/or this documentation: https://realpython.com/python-dicts/The last thing we have to change is how we are calling the
get_average_rating
function. We need to change it frombook.get_average_rating[book]
tobook.get_average_rating()
.This change is necessary because
get_average_rating
is a function defined in ourBook
object. To call this function, we need to access that function from the Book object (e.g.book
) and then pass it the necessary parameters. In this case, the function has no parameters, so we can simply call the function like so:book.get_average_rating()
.If you have any further questions about calling class functions and/or class concepts, please refer back to the Codecademy lessons.
The text was updated successfully, but these errors were encountered: