Problem with blossom

So I am having this problem with the project. I’ve done it and after looking at the solution to double check it seems like it should have worked fine. I had to do some manual troubleshooting on my own but after I fixed those problems I got this issue

Traceback (most recent call last):
File “script.py”, line 37, in
blossom.assign(flower[0], flower[1])
File “script.py”, line 19, in assign
list_at_array = self.array[array_index]
IndexError: list index out of range

I don’t understand what I did wrong? I went on to almost rewrite the whole thing after the solution but I still got nothing.

The error message tells you that array_index is out of range for self.array. Have you tried printing out both of those to see why that may be? Print statements are your best friend when you are debugging.

2 Likes

Hi @salimfarhat,

When asking a question about a project or lesson, it is a good idea to provide a link to the instructional material so that users who wish to help can conveniently find the instructions.

The link to this project is Blossom.

@el_cocodrilo’s advice may help you find the problem. Please let us know how it works out.

Blockquote The error message tells you that array_index is out of range for self.array . Have you tried printing out both of those to see why that may be? Print statements are your best friend when you are debugging.

They said that neither of those things were defined. Which I find to be quite odd.

Ok everyone I followed the entire walkthrough and it turns out I did one mistake on line 13. It had to be hash_size % self.array_size.

what I did was had those two values reversed, it was self.array_size % hash_size, this was the problem.

I noticed that my biggest challenge is just misunderstanding what the instructions want. I often do a sort of correct statement… but where the stuff has to be is reversed. I need to work on that.

1 Like

@salimfarhat,

I’m glad that you were able to figure it out by going through the exercise again. I definitely had to start over a few times when I was learning certain concepts.

As far as the print statements for array_index and self.array, those print statements should have been inside the class method where you were trying to use those values. If you tried to print them outside of your class and before you instantiated a class object, they would have said those values were undefined.

Anyway, the learning process can have its ups and downs, but as long as you keep at it, you’ll get it.

Happy coding!