Course 5 Week 1 Assignment 3 Exercise 3 "predict_and_sample"

In the final exercise, the “predict_and_sample” function keeps throwing this error. I do not seem to see where the bug is. Can I get some help please? I believe I’m implementing the code properly.

The error says that you are trying to access an elements that does not exist. So the results array size is not 12 (actually 13 because it starts from 0), its less than 13. Wherever the results array is produced you need to go there and check why this arrays is not producing enough elements for the test to get through!

Yes, I figured that could be the situation but I don’t know how I can resolve it. I’ve looked into my code and I believe it’s in order although when I used print commands to investigate the outputs at various lines, I don’t think they’re in order. I suspect the issue could be from my model itself but since all previous unit tests have been passed, I’m not sure how to go about the debugging process…