This 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) print_board(board) def random_row(board): return randint(0, len(board) - 1) def random_col(board): return randint(0, len(board) - 1) shiprow = random_row(board) shipcol = random_col(board) guessrow = int(raw_input("Guess Row:")) guesscol = int(raw_input("Guess Col:")) print shiprow print shipcol #Write your code below! if (shiprow == guessrow) and (shipcol == guesscol): print "Congratulations! You sank my battleship!" else: print 'You missed my battleship!' board[guessrow][guesscol] = "X" print_board(board)
I get this error -
Traceback (most recent call last):
File "python", line 33, in
IndexError: list index out of range
Can someone help please?????