It does not let me writte the second input


#1

Hello,

In the following exercise “https://www.codecademy.com/courses/learn-python/lessons/battleship/exercises/you-win?action=resume_content_item” ( Battleship! lesson, exe 10), the code output does not allow me to input the column guess. It prints the message in front of the ‘Guess Col:’ line.

Here is my code so far:
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)

ship_row = random_row(board)
ship_col = random_col(board)
print ship_row
print ship_col
guess_row = input("Guess Row: ")
guess_col = input("Guess Col: ")

Write your code below!

if guess_row == ship_row and guess_col == ship_col:
print “Congratulations! You sank my battleship!”
else:
print ‘You missed my battleship!’
board[guess_row][guess_col] =‘X’
print_board(board)

Can someone explains to me what’s going on!
Attached I also send the output.

code_aca_error|516x500 please?

Many thanks


#2

For this lesson, it may be necessary to manually set those two variables to some values that are within range, or just copy the ship_row and ship_col variables. Comment out the inputs.