Skip to Content
Custom Print

Now we can see the contents of our list, but clearly it would be easier to play the game if we could print the board out like a grid with each row on its own line.

We can use the fact that our board is a list of lists to help us do this. Let’s set up a for loop to go through each of the elements in the outer list (each of which is a row of our board) and print them.



First, delete your existing print statement.

Then, define a function named print_board with a single argument, board_in.

Inside the function, write a for loop to iterates through each row in board and print it to the screen.

Call your function with board to make sure it works.

Folder Icon

Take this course for free

Already have an account?