Function help.

Okay guys here it is so far.

import sys



def main():

# Call function readPuzzle() to read data file into puzzle object

puzzle = readPuzzle()

# Create 15 x 15 game grid, initially filled with blocks ('*')

#grid = [['*' for x in range(15)] for x in range(15)]
grid = createGrid(puzzle)

# Iterate through every word in the puzzle, adding each word to the grid

for i in puzzle:
    addWordToGrid(puzzle[i], grid)

# Print the fully-populated grid to the console

printGrid(puzzle, grid)
# Pause before exiting the program
print( findWord(puzzle, 1, "A") )
input('Press ENTER: ')



def readPuzzle():

#
# READ THE PUZZLE DATA FILE INTO A DICTIONARY
#

# This function should: open the data file, read each line (representing a
# word), split each line into a list (representing the properties of the
# word), store these properties into a dictionary with sensible key names,
# and add these dictionaries into the main dictionary 'puzzle', using the
# word as the key name.  Finally, return the 'puzzle' dictionary to the
# caller.

puzzle = {}
input_file = open("puzzle.csv" ,'r')

line = input_file.readline()

while ( len(line) > 0 ):

    line = line.strip()

    linelist = line.split('\t')

    word = {}

    word["y"] = int(linelist[0])
    word["x"] = int(linelist[1])
    word["box"] = int(linelist[2])
    word["direction"] = linelist[3]
    word["word"] = linelist[4]
    word["clue"] = linelist[5]

    puzzle[ linelist[4] ] = word

    line = input_file.readline()
#print(puzzle.keys())

return puzzle



def addWordToGrid(newword, grid):

#
# ADD A WORD TO THE GRID
#

# This function should: accept a word dictionary ('newword') and the grid
# object ('grid') as arguments, and add each letter of 'newword', one by
# one, into the correct squares of the grid, replacing any letters or
# blocks already in these squares.  (Remember that the word dictionary
# includes all of the properties of the word, including the X and Y
# coordinates of the first letter of the word and each letter of the word.
# You can use this information to determine the correct square for every
# letter of the word.)  This function does not have to return a value to
# the caller.

word = newword["word"]
x = newword["x"]
y = newword["y"]
direction = newword["direction"]

wordlist = list(word)

for i in range(0, len(word)):

    grid[y][x] = wordlist[i]

    if (direction == "A" ):
        x += 1
    elif(direction =="D" ):
        y += 1



def createGrid(puzzle):
 # CREATE A NEW GRID, FILLED WITH BLOCKS
 grid = [['*' for x in range(15)] for x in range(15)]
 # LOOP THROUGH ALL WORDS IN THE PUZZLE
 for i in puzzle:
      # GET INFORMATION ABOUT THE NEXT WORD
      word = puzzle[i]["word"]
      x = int( puzzle[i]["x"] )
      y = int( puzzle[i]["y"] )
      direction = puzzle[i]["direction"]
      # LOOP THROUGH EACH LETTER OF THE NEXT WORD
      for j in word:
           # PUT AN EMPTY SPACE IN THE GRID
           grid[y][x] = " "
           # MOVE ON TO THE NEXT LETTER
           if direction == "A":
                x += 1
           elif direction == "D":
                y += 1
 # RETURN THE EMPTY GRID
 return grid

def findWord(puzzle, box, direction):
 # LOOP THROUGH ALL WORDS IN THE PUZZLE
 for i in puzzle:
      # GET DICTIONARY FOR NEXT WORD
      newword = puzzle[i]
      # GET DIRECTION AND BOX NUMBER FROM DICTIONARY
      newworddirection = newword['direction']
      newwordbox = newword['box']




      # COMPARE THE DIRECTION AND BOX NUMBER WITH THOSE PROVIDED
      # IN THE ARGUMENTS; IF BOTH MATCH, RETURN "NEWWORD" TO THE
      # CALLER (INSERT YOUR CODE HERE)
      newworddirection = input('Which Direction?: ')
      newwordbox = input('Box number?: ')
      if newworddirection == newworddirection and newwordbox == newwordbox:
          return newword
      else:
          return None

 # RETURN "NONE" IF NO MATCH WAS FOUND




def printGrid(puzzle, grid):

#
# PRINT THE GAME GRID TO THE CONSOLE
#

# Begin by creating a new two-dimensional array for the box numbers

boxnumbers = [[0 for x in range(15)] for x in range(15)]

# Next, loop through all the words in the puzzle to get the box numbers

for i in puzzle:

    # Get the next word in the puzzle

    nextword = puzzle[i];

    # Retrieve the X and Y of the first letter, along with the box number

    x = int(nextword['x'])
    y = int(nextword['y'])
    box = int(nextword['box'])

    # Add the box number to the array

    boxnumbers[y][x] = box

# Now, print the grid to the console

for y in range(0,15):

    # Print the top border of the next row, box by box

    for x in range(0, 15):

        # If there is no box number on this box, print an empty top

        if ( boxnumbers[y][x] == 0 ):
            sys.stdout.write('+---')

        # If there is a single-digit box number, print it in the center

        elif ( boxnumbers[y][x] < 10 ):
            sys.stdout.write('+-' + str(boxnumbers[y][x]) + '-')

        # If there is a double-digit box number, print it at the left edge

        elif ( boxnumbers[y][x] >= 10 ):
            sys.stdout.write('+' + str(boxnumbers[y][x]) + '-')

    # End the top border and begin printing the next row

    sys.stdout.write('+\n|')

    # Print the next row, box by box, padding each letter with spaces

    for x in range(0,15):

        sys.stdout.write(' ' + grid[y][x] + ' |')

    print()

# Print the bottom border for the grid

print('+' + '---+' * 15)

main()

/r/learnpython Thread