Course 5, week 1, assignment 2, sample()

I am hitting an error about the append. In the previous assignments, it works well, but why it shows an error like this?
image

1 Like

Maybe there is no variable named ā€œindicesā€ in your code.

Hi TMosh,

I think the variable ā€˜indicesā€™ was defaultly defined by the notebook as an empty list.

Chito

You are correct. And there is nothing wrong with this line of code:
indices.append(idx)

The syntax error is probably caused by a previous line of code.

@Chitoooo , did you find the problem by now?
I encounter exactly the same error message and donā€™t have any idea where it is coming from.

That type of syntax error most commonly means that there is something incomplete about the previous line of code: e.g. a missing close parenthesis.