You win!


#1

Hey, I can't seem to understand what I'm doing wrong..

That's my code:

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 ship_row
print ship_col

Write your code below!

if guess_row==ship_row and guess_col==ship_col:
print "Congratulation! You sank my battleship!"

that's the consule:
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: 3
Guess Col: 1
3
1
Congratulation! You sank my battleship!
None

this is the message I get when I try to move forward:
Oops, try again. Did you remember your print statement that prints "Congratulations! You sank my battleship!" ?

Help me I'm lost..


#2

Your string is

but it should be,

Congratulation s ! You sank my battleship!

so to fix the error just change your print statement to,

print "Congratulations! You sank my battleship!"


#3

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