Skip to content

Re: the 'not hashable' error you mentioned with your first attempts #4

@karl-project-review

Description

@karl-project-review

#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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions