Why Do These `print`s Not Work?


#1

Hi,
I have 2 questions:
first, in the code below, at the bottom line I use PRINT but after running the code nothing happens! why is that?
board = []

for i in range(5):
board.append([“O”] * 5)

def print_board(board):
for row in board:
print board

and my second question is, after using CUSTOM PRINT command in the code bellow I will get an error! do I use the PRINT command wrong?
board = []

for i in range(5):
board.append([“O”] * 5)

def print_board(board):
for row in board:
print " ".join(board)


FAQ: Learn Python - Battleship - Custom Print
#2

functions only execute when called, you don’t have a function call

you try to join board:

print " ".join(board)

why?


#3

Thank you. I almost got them all.
what is still confusing for me is, what is the difference between CALLING and PRINTING?
After defining a function should we call it to make it printed or use the print command?


#4

easier said then done, in python2 (which codecademy is using) print is a statement, in python3 print() is a function call

but in this case, i mean you need to call your print_board function. defining a function is like making a task list, you just write down the the tasks, you haven’t actually preformed them. Which is where function calls come into play, they trigger the completion of the task list

if you are unclear about function, you might want to recap some of the lessons