Issue with last assigment of Neural Networks and Deep Learning course

hi guys,
actually i h have problem with the last assigment of the first course in this specialization

i have issue with two_layer_model function
i have this error

ndexError Traceback (most recent call last)
in
1 parameters, costs = two_layer_model(train_x, train_y, layers_dims = (n_x, n_h, n_y), num_iterations = 2, print_cost=False)
2
----> 3 print("Cost after first iteration: " + str(costs[0]))
4
5 two_layer_model_test(two_layer_model)

IndexError: list index out of range

can any one help me

Dm let’s learn together +233558020084 I’m also taking that course

The error suggests that costs[0] is not valid. Are you certain that costs is a vector?

i should mention that i have tis bug since two months almost
normaly i dont have any syntaxe bugs in the code but here is
actually for the list costs i dont have any acess to the first element here is the code.

{moderator edit: code removed}

… and here is the code of the assignment

parameters, costs = two_layer_model(train_x, train_y, layers_dims = (n_x, n_h, n_y), num_iterations = 2, print_cost=False)

print("Cost after first iteration: " + str(costs[0]))

two_layer_model_test(two_layer_model)

and here is the error :sa:
IndexError Traceback (most recent call last)
in
1 parameters, costs = two_layer_model(train_x, train_y, layers_dims = (n_x, n_h, n_y), num_iterations = 2, print_cost=False)
2
----> 3 print("Cost after first iteration: " + str(costs[0]))
4
5 two_layer_model_test(two_layer_model)

IndexError: list index out of range

There is no syntax error. There is a runtime error though. This is a fairly easy problem to debug if you follow the evidence.

If print_cost is False, then your code for costs.append(cost) never runs. It’s inside an if-statement that tests print_cost.

Did you perhaps modify this line of code in the notebook? Because print_cost shouldn’t be used there.
image

yeah i think that i have modified the code by mistake
so could you send me the right version of cide tò submit
i thank you in advance

Here is how it should look:
image

If you need a new copy of the notebook, you can get that via the instructions in the DLS FAQ. You can find it in the DLS Resources area, by using the forum search tool.

Note that I have edited this thread to remove your code - sharing your code is not allowed by the Code of Conduct.