Danger, Will Robinson!


#1



Oops, try again. It looks like your game does not print "You missed my battleship!" when the guess is wrong.

https://www.codecademy.com/courses/python-beginner-en-4XuFm/1/2?curriculum_id=4f89dab3d788890003000096


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

ship_row = random_row(board)
ship_col = random_col(board)
guess_row = int(raw_input("Guess Row:"))
guess_col = int(raw_input("Guess Col:"))

print "Actual location: " + str(ship_row) +", " + str(ship_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 batteship!"
    board[guess_row-1][guess_col-1] = "X"
    print_board(board)
    print "You missed my batteship!"


So despite the error I'm getting, the result in the console seems to be correct... I even added that "You missed my battleship!" line in twice, but it still doesn't register it.. here is the output in the console:

O O O O O
O O O O O
O O O O O
O O O O O
O O O O O
Guess Row: 4
Guess Col: 4
Actual location: 0, 0
You missed my batteship!
O O O O O
O O O O O
O O O O O
O O O X O
O O O O O
You missed my batteship!
None

I have tried refreshing the page/window and it is still the same.
Any ideas? Please help.


#2

Printing the typo any number of times will not matter.

battleship!


#3

So this is what staying up til 5 am trying to learn basic coding does to my brain :confused:


#4

There are good days, and there are better days. We all have our good days. Welcome to the club. And remember to take a break now and then so you can regain focus. If you are under 20 years old you still need 9 to 10 hours of sleep, a night, in one go. Yeah, 5 AM is hardly one's finest hour. Look after yourself.