# Wee4 - Exercise 5 L_model_forward

Hello,

For this exercise, I wrote the correct code but honestly I don’t get it.
the for loop ends with the final layer so at the end of the for loop we have the result of the AL.

At this point A = AL, so when implementing AL using segmoid I don’t get how the code is runing.
Please, show me where i got it wrong.

Thank you

The thing to realize is that loop indices work the same way as array indices in python: they are zero based. So if an array has 4 elements, the last one is myArray[3], right? Run the following code and watch what happens:

``````for ii in range(1,5):
print(f"ii = {ii}")

print(f"ii after loop = {ii}")
``````

The net result of the above analysis is that when you fall out of the for loop, you have the A^{[l]} value that was output by the last hidden layer. Then you need to code the forward propagation for the output layer using “sigmoid” as the activation.

Hello,

Thank you very much, The thing is I didn’t know how a for loop is runing in fact.
I got it now.

Thanks a lot

Python is an interactive language. When you don’t know how something works, you just have to try it, right? E.g. you could have put print statements in the loop to see what was happening.

1 Like