Hide


#1

Hello,

I am getting an error through CC with the following code. The error is: It looks like your row bounds are not correct.
My code is:
rom 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):
randint(0, len(board) -1)
def random_col(board):
randint(0, len(board) -1)
random_row(board)
random_col(board)

Also, I am trying this exercise in Python 3 and get the error: Traceback (most recent call last):
File "/Users/btome/Desktop/Battleship.py", line 13, in
random_row(board)
File "/Users/btome/Desktop/Battleship.py", line 12, in random_row
randit(0, len(board) -1)
NameError: name 'randit' is not defined

I know I have spelling errors, but Python will not let me edit. If I try to highlight anything, I am only able to capture entire rows and I am not able to type anything within the code. Any suggestions?

Thanks in advance


#2

Hi, bdt9123,

seeing your error it seems the randit function does not get imported. Your code is off in line one.
It should be "from...". Next to that I do not know why you can't edit.
Regards


#3

Thanks @lakensrpr. That fixed my code.


#4

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