Printing the board


#1



It says:
Oops, try again. Did you remember to print your board?

I used the code snippets of developers in this site. It keeps saying an error for printing the board.


board=[]

for x in range(5):
    board.append(["O"] * 5)
def print_board(board):
    for row in board:
        print " ".join(row)

print_board(board)


#2

Hi!

This block is in the for loop, and as such, should follow same indentation level.

board = []
for i in range(5):
    board.append(["O"]*5)
    def print_board(board):
        for row in board:
            print " ".join(row)
    print_board(board)

I hope this helps.


#3

I tried what you posted. But it didn't work.
Thanks in advance.


#4

yep!
not working in my case also


#5

@hkocaman && @anshika97 . Sorry it didn't work. Can you post your new code and the resultant errors?

Thank you! :slight_smile:

Meanwhile, still on your code @hkocaman , here is the recommended code formatting, which works fine.

board = []
for i in range(5):
    board.append(["O"]*5)
    def print_board(board):
        for row in board:
            print " ".join(row)
    print_board(board)

#6

board = []

for x in range(5):
    board.append(["O"] * 5)

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

Here is my code that I took from this forum. I saw that almost everybody I looked at did the way as above. I also tried to use your version. However it did not work. İt printed 25 lines of "O"s and also printed ;
Oops, try again. Did you remember to print your board?

Thank you :slight_smile:


#7

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