Hash_map. encode() and key_bytes question

Below is the URL

My question is in class HashMap, there is a function encode(). What does it return? And sum(key_bytes) returns an integer. I thought key_bytes were a string. Does function sum() convert it into integer?

You must select a tag to post in this category. Please find the tag relating to the section of the course you are on E.g. loops, learn-compatibility

When you ask a question, don’t forget to include a link to the exercise or project you’re dealing with!

If you want to have the best chances of getting a useful answer quickly, make sure you follow our guidelines about how to ask a good question. That way you’ll be helping everyone – helping people to answer your question and helping others who are stuck to find the question and answer! :slight_smile:

You can always hunt down what str.encode does in the docs-

Short version is that it returns a bytes object (sequence of individual bytes, default encoding is utf-8) and I’m not 100% but I’m guessing sum() adds up the decimal representation of each of those bytes providing you with an integer value.