0
$\begingroup$
N = int(input('number of traverse='))
x = []
y = []
for r in range(N):
    x.append([float(input('enter x='))])
for l in range (N) :
    y.append([float(input('enter y='))])

N=N-1
b=int(N)
area = x[0] * (y[1] - y[b]) + x[b] * (y[0] - y[b-1])

for k in range(1, N):
    area = area + x[k] * (y[k+1] - y[k - 1])
    i=i+1
area = .5 *abs(area)**strong text**
```
$\endgroup$

1 Answer 1

2
$\begingroup$

The problem is x[0] etc are resulting in a 1D list. You need to extract element from 1D list.. below works (I used index 0 element)

area = x[0][0] * (y[1][0] - y[b][0]) + x[b][0] * (y[0][0] - y[b-1][0])
$\endgroup$
1
  • 1
    $\begingroup$ that is right thank you.. $\endgroup$ Mar 17, 2020 at 11:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.