Why do I keep getting a syntax error message (in Python) when using append?

The syntax error is at line 9.

# -*- coding: UTF-8 -*-
import math
x = []
y = []
n = raw_input('How many points: ')
number = n
while n > 0:
  x.append(input('enter x: ')
  y.append(input('enter y: ')
  n = n - 1
d = []
n = number
while n > 0:
  d.append(math.sqrt((x[n-1] - x[n-2])**2 + (y[n-1] - y[n-2]**2
  n = n - 1
d.append(math.sqrt((x[number-1] - x[0])**2 + (y[number-1] - y[0]**2
p = 0
n = number
while n > 0:
  p = p + d[n-1]
  n = n - 1
print(‘Perimeter =’)
print(p)
input(‘Press 0 and then enter to continue:’)

What am I doing wrong? Also, I am only a beginner in Python, so an easy to understand explanation would be helpful.

This is what is popping up in my terminal:

File "prg1.py", line 9
    y.append(input('enter y: ')
    ^
SyntaxError: invalid syntax


Source: syntax

Leave a Reply