Error in W1 program exercise 2 part2

In the sample() function I have code below

while (idx != newline_character and counter != 50):
        
        # Step 2: Forward propagate x using the equations (1), (2) and (3)
        a = np.tanh(np.dot(Wax, x) + np.dot(Waa, a_prev) + b)
        z = np.dot(Wya, a) + by
        y = softmax(z)
        
        # For grading purposes
        np.random.seed(counter + seed) 
        
        # Step 3: Sample the index of a character within the vocabulary from the probability distribution y
        # (see additional hints above)
        idx = np.random.choice(list(range(len(vocab_size)), p =y.ravel())

        # Append the index to "indices"
        indices.append(idx)
        
        # Step 4: Overwrite the input x with one that corresponds to the sampled index `idx`.
        # (see additional hints above)
        x =np.zeros(shape = (vocab_size,1))
        x[idx] = 1
        
        # Update "a_prev" to be "a"
        a_prev = a
        
        # for grading purposes
        seed += 1
        counter +=1```
and get the error like here 
File "<ipython-input-25-8fbe214c5ea4>", line 61
    indices.append(idx)
          ^
SyntaxError: invalid syntax


can someone help?
1 Like

@PXPX11 The code line for idx assignment is missing a closing parenthesis.

3 Likes

Particularly in the idx assignment in step-3.

2 Likes

@PXPX11
Also, please edit your message to remove the code. Posting your code breaks the course Honor Code.

1 Like