C5 W1A2 Dinosaur lab - model function

Hello everyone, I am having trouble with the model function in the dinosaur lab. When running I am getting the error:

   101         # Update the loss by substracting the cross-entropy term of this time-step from it.
--> 102         loss -= np.log(y_hat[t][Y[t],0])
    103 
    104     cache = (y_hat, a, x)

IndexError: list index out of range

Following is my code. I can’t figure out what I am doing wrong. It must be in the way X and Y are encoded (everything else is already set in the script). Still, I can’t figure it out. Must be one of those simple things I can’t quite spot… Thank you for any help you could provide.
Tiziana.

{moderator edit: code removed}

In the future, please do not post your code on the forum. That is not allowed by the Code of Conduct.

If a mentor needs to see your code, we’ll contact you with instructions.

Hints:

For ix_newline, you know that’s a single character, so you don’t need an iterator. Just …
ix_newline = [char_to_ix["\n"]]
… is sufficient. Probably not an error, but not very tidy.

Y = single_example_ix[1:]+ix_newline

Here, you already have X = [None] + single_example_ix, so for Y you only need
Y = X[1:] + ix_newline
Again, probably not an error.

But here’s your “list index” error:

# Choose a learning rate of 0.01
 print("len(Y)="len(Y))

Because, your print statement is missing a comma.

Thank you very much!
I apologize for posting the code, I guess I have not thought it through. Can I do anything now to delete it and minimize the “damage”?
Thank you for your clarifications! A comma in a not-needed print! I was getting an error that made me think of something much more complex. Thank you again for your help with this issue.
Happy holiday seasons.
Tiziana.

I already removed the code, don’t worry about it.