目标是计算n边多边形的周长。我正在尝试使用列表x和y,但我一直遇到“ for循环”中的错误。我可以做些什么?
from math import sqrt
x = []
y = []
distance = []
perimeter = sum(distance)
while True:
x.append(int(input('Enter x value of a point: ')))
y.append(int(input('Enter y value of the point: ')))
if x[-1] == 0 and y[-1] == 0:
break
for i,j in (x, y):
distance = sqrt((abs((x[i]) - (x[i+1])))**2 + (abs((y[i]) - (y[i+1])))**2)
print(perimeter)```