Why do I keep getting a syntax error message (in Python) when using append?
Question: 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
    


Answer: There are so many errors of your code.

  1. as a function, input and append both need (), so line 8 and 9 should be
    
        x.append(input('enter x: '))
    y.append(input('enter y: '))
    

  2. the type of 
    
        raw_input('How many points: ') 
    

is string, if you need add 1 to n, you should convert it to int using int()
function.

  3. append(),sqrt() also missing ')' .

