Don't know what to do (Python lesson-9/19(Battleship))

Hi,

I am not sure what to do in 9/19(Battleship) problem. It says "Before the lines prompting the user for input:

Print the value of ship_row.

Print the value of ship_col."

So should I copy the full program from 8/19 and then write inset "Print the value of ship_row.

Print the value of ship_col." above the lines prompting for user input ? I tried doing that but it kind of freezes and does not show me anything. Please help.

Please remember to include a link to the exercise when posting a new topic. Thank you.

1 Like

https://www.codecademy.com/courses/learn-python/lessons/battleship/exercises/its-not-cheatingits-debugging?action=lesson_resume

Here is the link.
Do you have any siggestions?

# Add your code below!

print ship_col
print ship_row

guess_row = int(raw_input("Guess Row: "))
guess_col = int(raw_input("Guess Col: "))
1 Like

I wrote the code you have given. It is still showing the waiting sign. Is it because it is having a hard time generating the random integers?

No, the random number generator is very fast. You may need to do a page refresh and Run. Be sure to input the same numbers displayed (not that it matters, yet) but that is the point.

1 Like

Not sure what you mean by “Be sure to input the same numbers displayed”

I think I got your point. I tried refreshing it. It does not help

At this point it really does not matter, but it will in the next few lessons. Just be sure to input something so the program can end.

1 Like

This is my code. I don’t know what’s wrong with it. It’s not working. 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_in):
return randint(0, 4)

def random_col(board_in):
return randint(0, 4)

ship_row = random_row(2)
ship_col = random_col(2)

Add your code below!

print ship_row
print ship_col

guess_row=int(raw_input(“Guess Row:”))
guess_col=int(raw_input(“Guess Col:”))

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