I'm writing a program for creating a puzzle solver. I have created a class that defines a board and has the init and get function. I am then defining a function that initializes a board based on two inputs. The board is a list of lists and each list contains numbers 1 - n depending on the input except the bottom right is 0. For some reason when I attempt to return an object of the class in my function, it tells me the class is not defined. (global name 'TilePuzzle' is not defined)
def create_tile_puzzle(rows, cols):
    count = 1
    b = [[] for x in range(rows)]
    for i in range(rows):
         for j in range(cols):
            b[i].append(count)
            count += 1
    b[rows-1][cols-1] = 0
    print b
    return TilePuzzle(b)
print create_tile_puzzle(4, 4)
class TilePuzzle(object):
    def __init__(self, board):
        self.board = board
    def get_board(self):
        return self.board
