Battleship....and SEEK


#1


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


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:"))


#2

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


#3

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


#4

Remove the space from in front of guess...


#5

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


#6

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