Printing Pretty 6/18


#1

Hello this is my code:

board = []

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

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

It works. But on the community forums I see a lot of people with this as the correct code:

board = []

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

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

print_board(board)

So the only extra thing is the ‘print_board(board)’ at the end. What difference does it make? Help me please.


#2

print_board(board) is a function call, it executes it. Without it, the board won’t be printed pretty. (given a function call executes a function)


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.