+ 3
Need help Python
I have problem https://code.sololearn.com/c7v23dFh7Ns0/?ref=app
4 Answers
+ 5
Please put your code on sololearn playground.
If you paste it into the comment like this, indentation gets messed up, we can't test it and don't know what line 16 is.
+ 4
Thanks for your answer. Now I test it.
+ 2
import math
import numpy as np
n = int(input())
ce1=[0,0]
ce2=[2,2]
cl1=np.empty((0,2), float)
cl2=np.empty((0,2), float)
for i in range(n):x=[float(j) for j in input().split()]
d21=(np.array(ce1)-np.array(x))**2
d1=math.sqrt(d21.sum())
d2=math.sqrt(((np.array(ce2)-np.array(x))**2).sum())
if d1<=d2: cl1=np.append(cl1,np.array([x]),axis=0)
else: cl2=np.append(cl2,np.array([x]),axis=0)
if len(cl1) != 0: nce1=np.mean(cl1,axis=0).round(2)
print(nce1)
else:
print (None)
if len(cl2) != 0: nce2=np.mean(cl2,axis=0).round(2)
print(nce2)
else:
print(None)
+ 2
Artem Kirichenko
I am unable to see the indentation
and I can see that none is not put in between quotes so its checking if there is a variable declared as none and maybe its giving the error
Check it and if correct give me an upvote so that i can see that if my answer is helpful