(Python) Idk what to do : <p>So I was learning how to make a tic tac toe game from a website and when I finished, I couldn't play it because I keep getting the same error, I checked my work and every thing was fine, here's the code</p>

<pre><code>import random
from time import sleep
print "To play this game, you use your 1-9 keys"
print "This is layout of each number representing a square"
print "7|8|9"
print "4|5|6"
print "1|2|3"
print " "
def drawboard(board): #Draws the board
    print "Board"
    print '' + board[7] + '|' + board[8] + '|' + board[9]
    print '' + board[4] + '|' + board[5] + '|' + board[6]
    print '' + board[1] + '|' + board[2] + '|' + board[3]

def inputplayerletter(): #Asks player if they want to be X or O
    letter = ''
    while not letter == 'X' or letter == 'O':
        print "Do you want to be X or O?"
        letter = raw_input(" ").upper()
    if letter == 'X':
        return ['X', 'O']
    else:
        return ['O', 'X']

def whogoesfirst(): #This determines who goes first
    if random.randint(0,1) == '0':
        return 'computer'
    else:
        return 'player'

def playagain(): #Asks player if it wants to play again
    print "Do you want to play again?(Y/N)"
    return raw_input("").lower().startswith('y')

def makemove(board, letter, move): #When someone makes a move we execute this function
    board[move] = letter

def winner(bo,le): #Determines whose the winner
    return ((bo[7] == le and bo[8] == le and bo[9] == le) or
    (bo[4] == le and bo[5] == le and bo[6] == le) or
    (bo[1] == le and bo[2] == le and bo[3] == le) or
    (bo[7] == le and bo[4] == le and bo[1] == le) or
    (bo[8] == le and bo[5] == le and bo[2] == le) or
    (bo[9] == le and bo[6] == le and bo[3] == le) or
    (bo[7] == le and bo[5] == le and bo[3] == le) or
    (bo[9] == le and bo[5] == le and bo[1] == le)


def getboardcopy(board): #Creates a copy of the board for the computer AI
    dupeboard = []
    for i in dupeboard:
        dupeboard.append(i)
    return dupeboard

def isspacefree(board, move): #Checks if space is free.
    return board[move] == ''

def playermove(board): #Where the player inputs his/her move
    move = ''
    while move not in '1 2 3 4 5 6 7 8 9'.split() or not isspacefree(board, int(move)):
        print "your move (Pick from 1-9)"
        move = raw_input("")
    return int(move)

def choosemovefromlist(board, movelist): #chooses possible moves from list
    possiblemoves = []
    for i in moveslist:
        if isspacefree(board, i):
            possiblemoves.append(i)
    if len(possiblemoves) != 0:
        return random.choice(possiblemove)
    else:
        return None

def computerai(board, computerletter): #Computer AI
    if computerletter == 'X':
        playerletter = 'O'
    else:
        playerletter = 'X'

    for i in range(1,10):
        dupe = getboardcopy(board)
        if isspacefree(copy, i):
            makemove(board, computerletter, i)
            if winner(copy, computerletter):
                return i
    for i in range(1,10):
        dupe = getboardcp[y(board)
        if isspacefree(copy, i):
            makemove(board, playerletter, i)
            if winner(copy, playerletter):
                return i
    move = choosemovefromlist(board, [1, 3, 7, 9])
    if move != None:
        return move
    if isspacefree(board, 5):
        return 5
    return choosemovefromlist(board[2,4,6,8])

def isboardfull(board):
    for i in range(1,10):
        if isspacefree(board, i):
            return False
    return True

print "Welcome to Tic Tac Toe!"

while True:
    theboard = [''] * 10
    print "Flipping the coin..."
    sleep(2)
    turn = whogoesfirst()
    print "The " + turn + " goes first."
    gameinprogress = True
    while gameinprogress:
        if turn == 'player':
            drawboard(theboard)
            move = getplayermove(theboard)
            makemove = (theboard, playerletter, move)
            if winner(theboard, playerletter):
                drawboard(theboard)
                print "The player wins the game! Congratulations!"
                gameinprogress = False
            else:
                if isboardfull(theboard):
                    drawboard(theboard)
                    print "Tie game! No one wins!"
                    break
                else:
                    turn = 'computer'
        else:
            move = computerai(theboard, computerletter)
            makemove(theboard, computerletter, move)
            if winner(theboard, computerletter):
                drawboard(theboard)
                print "The computer has beaten the player!"
                break
            else:
                turn = 'player'
    if not playagain():
        break
</code></pre>

<p>I keep getting an error here:</p>

<pre><code>def getboardcopy(board): #Creates a copy of the board for the computer AI
    dupeboard = []
    for i in dupeboard:
        dupeboard.append(i)
    return dupeboard

def isspacefree(board, move): #Checks if space is free.
    return board[move] == ''

def playermove(board): #Where the player inputs his/her move
    move = ''
    while move not in '1 2 3 4 5 6 7 8 9'.split() or not isspacefree(board, int(move)):
        print "your move (Pick from 1-9)"
        move = raw_input("")
    return int(move)

def choosemovefromlist(board, movelist): #chooses possible moves from list
    possiblemoves = []
    for i in moveslist:
        if isspacefree(board, i):
            possiblemoves.append(i)
    if len(possiblemoves) != 0:
        return random.choice(possiblemove)
    else:
        return None

def computerai(board, computerletter): #Computer AI
    if computerletter == 'X':
        playerletter = 'O'
    else:
        playerletter = 'X'

    for i in range(1,10):
        dupe = getboardcopy(board)
        if isspacefree(copy, i):
            makemove(board, computerletter, i)
            if winner(copy, computerletter):
                return i
    for i in range(1,10):
        dupe = getboardcp[y(board)
        if isspacefree(copy, i):
            makemove(board, playerletter, i)
            if winner(copy, playerletter):
                return i
    move = choosemovefromlist(board, [1, 3, 7, 9])
    if move != None:
        return move
    if isspacefree(board, 5):
        return 5
    return choosemovefromlist(board[2,4,6,8])

def isboardfull(board):
    for i in range(1,10):
        if isspacefree(board, i):
            return False
    return True

print "Welcome to Tic Tac Toe!"
</code></pre>

<p>even if I remove a defined function here, another error appears. </p>

<p>So when I ran the code normally, this is the error I get</p>

<pre><code>Traceback (most recent call last):
  File "python", line 49
    def getboardcopy(board): #Creates a copy of the board for the computer AI
      ^
SyntaxError: invalid syntax
</code></pre>

<p>So when I remove that defined function from my code, I get this error:</p>

<pre><code>Traceback (most recent call last):
  File "python", line 50
    def isspacefree(board, move): #Checks if space is free.
      ^
SyntaxError: invalid syntax
</code></pre>

<p>Even if I remove that function too, the same error happens to the function after this function, and then if I remove every single function starting from def getboardcopy, I get an error at my print statement. Then when I remove that I get another error from the while loop. I'm using Python 2.7.2</p>
