Battleship....and SEEK


Oops, try again. Your code threw the following error: unexpected indent (python, line 22)

File "python", line 22
guess_row = int (raw_input ("Guess Row:"))
IndentationError: unexpected indent

This piece of code look all right..but gives error everytime....PLEASE HELP..

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[0]) - 1)

ship_row = random_row(board)
ship_col = random_col(board)

# Add your code below!
 guess_row = int (raw_input ("Guess Row:"))
 guess_col = int (raw_input ("Guess Col:"))


Those two lines have a single leading space that needs to be removed.


Thanks. But I tried all the variants to address the indent error. But did not yield success.


Remove the space from in front of guess...


A post was split to a new topic: I have one question


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