I have no idea what's wrong


#1



Here is my code:
from random import randint 

board = []

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

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

# Add your code below!
def random_row(board):
    return randint(0, len(board) - 1
def random_col(board):
    return randint(0, len(board) - 1
random_row(board)
random_col(board)

It keep giving me this error:

 File "python", line 15
    def random_col(board):
      ^
SyntaxError: invalid syntax

Any ideas what's wrong?


#2

HI you forgot to close randint()

def random_row(board):
    return randint(0, len(board) - 1
def random_col(board):
    return randint(0, len(board) - 1

#3

Thanks, that worked, but it's now saying: Oops, try again. It looks like your row bounds are not correct.


#4

SO your code is like that?

from random import randint 

board = []

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

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

# Add your code below!
def random_row(board):
    return randint(0, len(board) - 1)
def random_col(board):
    return randint(0, len(board) - 1)
    
random_row(board)
random_col(board)

#5

It's like this now:

from random import randint

board = []

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

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

Add your code below!

def random_row(board):
return randint(0, len(board)) - 1)
def random_col(board):
return randint(0, len(board)) - 1)

random_row(board)
random_col(board)


#6

its here

def random_row(board):
    return randint(0, len(board)) - 1)
def random_col(board):
    return randint(0, len(board)) - 1)

this part

len(board))

should be like that

len(board)

all this parts should be like that

def random_row(board):
    return randint(0, len(board) - 1)
def random_col(board):
    return randint(0, len(board) - 1)

#7

That's what I had before and it gave me this error message:

File "python", line 15
def random_col(board):
^
SyntaxError: invalid syntax


#8

Hi just ran it and it works can you post your code again?


#9

Here is my code


#10

Hi you still have the rand() open yous hould close it after the *- 1

return randint(0, len(board) - 1) <== add one  )

#11

That fixed it, but now it's saying: Oops, try again. It looks like your column bounds are not correct.


#12

YOu shoud do it inside the two function if you did it .. can you post your code?


#13

Nevermind, had the brackets in the wrong spot, fixed it now, It's working now. Thank you!


#14

There is a compiler issue with this code. I got an error multiple times but I ran the same code again and it worked. So, keep pressing the save & submit button. HAPPY CODING!


#15