# This is a misplaced bug report, if you wanna move it to the correct category

ok this site is super slow and I tried looking for the appropriate place to post this but I couldn’t really find it (afterwards I just found I should have done it inside the lesson, but I had already closed the lesson) and this is getting annoying since I’m literally just trying to help the site, so I’ll just post it here and you do with it what you will

Operating System: Windows 10
Browser: Brave
Course: Python 2
Lesson: Battleships!

Description: the way the lesson is structured it sort of makes you build the game wrong, because the position that’s shown on the board is based on the list index that starts on 0 and the user input uses normal starting in 1 counting.
So basically when I entered the values 3 and 3 the app would show it in the positions 4 and 4 on the board (which counting from zero would be 3 and 3).
Not only did the lesson tell me that was right but it also “unfixed” it after I fixed it.
Also, it told me to use range() but then it changed my code to 0 < x < 5.

This is the wrong code it told me was right, after it “unfixed” my code:

from random import randint

board = []

for x in range(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)
print ship_row
print ship_col

for turn in range(4):
guess_row = int(raw_input("Guess Row: "))
guess_col = int(raw_input("Guess Col: "))

if guess_row == ship_row and guess_col == ship_col:
print "Congratulations! You sunk my battleship!"
break
else:
if turn == 3:
print("Game Over")
if (guess_row < 0 or guess_row > 4) or (guess_col < 0 or guess_col > 4):
print "Oops, that's not even in the ocean."
elif(board[guess_row][guess_col] == "X"):
print "You guessed that one already."
else:
print "You missed my battleship!"
board[guess_row][guess_col] = "X"
print(turn + 1)
print_board(board)

This is my code in the very end after I re-fixed everything (just added -1 to the user input variable):

from random import randint

board = []

for x in range(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)
print ship_row + 1
print ship_col + 1

for turn in range(4):
guess_row = int(raw_input("Guess Row: ")) - 1
guess_col = int(raw_input("Guess Col: ")) - 1

if guess_row == ship_row and guess_col == ship_col:
print "Congratulations! You sunk my battleship!"
break
else:
if turn == 3:
print("Game Over")
break
elif guess_row not in range(5) or guess_col not in range(5):
print "Oops, that's not even in the ocean."
elif (board[guess_row][guess_col] == "X"):
print "You guessed that one already."
else:
print "You missed my battleship!"
board[guess_row ][guess_col] = "X"
print(turn + 1)
print_board(board)

tbh not even sure if you’re still maintaining the python 2 course but I thought I’d tell someone?

(Edit: Had to edit because I somehow ended up posting before I finished by mistake. This forum interface sucks.)