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.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?