6. printing pretty: PLEASE HELP


#1

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

def print_board(board):
for X in board:
" ".join(board)

print_board(board)

it says:
Oops, try again. Your code looks a bit off. Check the Hint if you need help! Your code threw the following error: sequence item 0: expected string, list found


#2

Your problem is here.

Think about what it says, "Expected string, but got a list".


#3

When i do that, it says:
Oops, try again. It looks like you function didn't print out the correct response!


#4

Did you read my post?

I didn't tell you to do anything...


#5

So what do i do to fix my code


#6

He told you took look at that section. The section he told you is where your problem is. We dont tell where your problem is, but just give you hints. Its much better to solve your own problems..


#7

@Ammar847 Remember that "[]" defines a list. The exercise is expecting a string. Recall that "" are what define a string.

Use this info to try and pass the exercise.


#8

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

def print_board(board):
for X in board:
" ".join(board)

print_board(board)

It says:
Oops, try again. It looks like you function didn't print out the correct response!


#9

What does the exercise ask for you to do?


#10

Here is something weird...


#11

Here is the code I used:
board = []
for i in range(0, 5):
board.append(["O"] * 5)
def print_board(board):
for a in range(len(board)):
print " ".join(board[a])
print_board(board)


#12

Hi guys :slight_smile:

can i ask is this completly correct way to pass this no6. excersise ?

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

print print_board(board)

O O O O O
O O O O O
O O O O O
O O O O O
O O O O O
None
None


#13

there should be a "space".join


#14

Hi guys,

This is my code (looks like many of yours' one):
board = []
for bo in range (5):
board.append(['O' * 5])
def print_board(board):
for row in board:
print("".join(row))
print(print_board(board))

This is console:
OOOOO
OOOOO
OOOOO
OOOOO
OOOOO
None
None

This is my problem: "It looks like not all of your rows have 5 columns."

Please, explain me my mistake.