Hide


#1

https://www.codecademy.com/en/courses/python-beginner-en-4XuFm/0/7?curriculum_id=4f89dab3d788890003000096#

I don't know what is wrong with my syntax. Please help me out
This is my error:
File "python", line 15
def random_col(board):
^
SyntaxError: invalid syntax

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)

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)

#2

In both random_row and random_col you are missing a closing parentheses after randint.
Change this

return randint(0,len(board-1)

To this

return randint(0,len(board-1))

#3

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