Knn code doubt solution

showing syntax error whereas in the video seems to work fine
https://drive.google.com/file/d/1f-uaxUPAh8k0uOM8eUjn575cgd8pJDby/view?usp=sharing

hey @rohit_1906 ,
You have by mistake missed a ) in code vals.append((p,y[i]) , so just add it at the end, It will work fine.

Thank You and Happy Learning :slightly_smiling_face:.

when i execute the next cell

showing this error

IndexError Traceback (most recent call last)
in
----> 1 pred = knn(x[0],y[0],xt[0])
2 print(pred)
3 plt.imshow(xt[0].reshape(28,28))
4 print(yt[0])

in knn(x, y, q, k)
6 for i in range(m):
7 p = dist(x[i],q)
----> 8 vals.append((p,y[i]))
9
10

IndexError: invalid index to scalar variable.

you need to change the command that you are using to call your function.
change it too pred = knn(x,y,xt)
it will work , currently you are actually passing only a scalar value as parameter , and hence it not able to iterate over it.

and do check your code once , its taking a lot of time to complete .