C5W1: Dinosaur Island - sample (exercise 2) - operands could not be broadcast together with shapes (27,) (22,)

When creating a post, please add:

Getting an error in Sample (Exercise 2)
Sampling:
list of sampled indices:
[23, 16, 26, 26, 19, 25, 22, 16, 7, 11, 17, 26, 23, 23, 23, 18, 10, 6, 12, 2, 14, 24, 14, 17, 7, 18, 0]
list of sampled characters:
[‘w’, ‘p’, ‘z’, ‘z’, ‘s’, ‘y’, ‘v’, ‘p’, ‘g’, ‘k’, ‘q’, ‘z’, ‘w’, ‘w’, ‘w’, ‘r’, ‘j’, ‘f’, ‘l’, ‘b’, ‘n’, ‘x’, ‘n’, ‘q’, ‘g’, ‘r’, ‘\n’]

ValueError Traceback (most recent call last)
in
19 print(“\033[92mAll tests passed!”)
20
—> 21 sample_test(sample)

in sample_test(target)
15 assert indices[-1] == char_to_ix[‘\n’], “All samples must end with \n”
16 assert min(indices) >= 0 and max(indices) < len(char_to_ix), f"Sampled indexes must be between 0 and len(char_to_ix)={len(char_to_ix)}"
—> 17 assert np.allclose(indices, [23, 16, 26, 26, 24, 3, 21, 1, 7, 24, 15, 3, 25, 20, 6, 13, 10, 8, 20, 12, 2, 0]), “Wrong values”
18
19 print(“\033[92mAll tests passed!”)

<array_function internals> in allclose(*args, **kwargs)

/opt/conda/lib/python3.7/site-packages/numpy/core/numeric.py in allclose(a, b, rtol, atol, equal_nan)
2157
2158 “”"
→ 2159 res = all(isclose(a, b, rtol=rtol, atol=atol, equal_nan=equal_nan))
2160 return bool(res)
2161

<array_function internals> in isclose(*args, **kwargs)

/opt/conda/lib/python3.7/site-packages/numpy/core/numeric.py in isclose(a, b, rtol, atol, equal_nan)
2258 yfin = isfinite(y)
2259 if all(xfin) and all(yfin):
→ 2260 return within_tol(x, y, atol, rtol)
2261 else:
2262 finite = xfin & yfin

/opt/conda/lib/python3.7/site-packages/numpy/core/numeric.py in within_tol(x, y, atol, rtol)
2244 def within_tol(x, y, atol, rtol):
2245 with errstate(invalid=‘ignore’):
→ 2246 return less_equal(abs(x-y), atol + rtol * abs(y))
2247
2248 x = asanyarray(a)

ValueError: operands could not be broadcast together with shapes (27,) (22,)

If this doesn’t help, please click my name and message your notebook as an attachment.

Got the issue. Thanks for the pointers