|
#I got a not hashable error here if I try to do the same as get_n_most_read-books |
|
def get_n_most_prolific_readers(self, num): |
Without looking at your original code, I can't say why exactly you were getting this error, but I was able to adapt your approach from the get_n_most_read_books method without any issues. I am including my code below (which ran successfully), which you can use to try to figure out what was off with your original code, if you are interested.
def get_n_most_prolific_readers(self, num):
n = 0
most_prolific = []
temp_dict = {}
for email, user in self.users.items():
temp_dict[email] = user.read_books()
while n < num and len(most_prolific) < len(self.users):
temp_most_pro = max(temp_dict, key = temp_dict.get)
temp_dict.pop(temp_most_pro)
most_prolific.append(temp_most_pro)
n += 1
return most_prolific
CodeAcademyPythonIntensive/TomeRater.py
Lines 326 to 327 in 4bc35a9
Without looking at your original code, I can't say why exactly you were getting this error, but I was able to adapt your approach from the get_n_most_read_books method without any issues. I am including my code below (which ran successfully), which you can use to try to figure out what was off with your original code, if you are interested.