Help! Course 5, week 1, Dinasour, UNQ_C2, "Wrong values"

I got this result, which is different from the expected result. I don’t know where is the problem.

list of sampled indices:
[11, 23, 16, 15, 1, 23, 23, 13, 17, 17, 0]
list of sampled characters:
[‘k’, ‘w’, ‘p’, ‘o’, ‘a’, ‘w’, ‘w’, ‘m’, ‘q’, ‘q’, ‘\n’]

There are lots of potential problems.

Did you try searching the Forum for “dino island” issues? There should be a lot of threads about this assignment.

Thanks sir for replying. I have searched the forum as you said but still can’t figure it out. Can I post my code here and then delete after addressing the issue?

I have found the solution. I calculate z with a_prev, which should have been a. Thank you so much.