I need help with the battleship section of python. I am in the 12th part and I am having a hard time with this. So hear are the codes that I tried that didn't work with me.

First one was:

if guess_col not in range(5) or guess_row 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."

Second one was:
if guess-row not in range(5) or \ guess_col not in range(5):
print "Oops, that's not even in the ocean."
print "You missed my battleship!"
guess_row, guess_col == "X"

Pleas help me!


how is the indention of your code? please format your code, so we can see it


elif board guess_row, guess_col == "X":

board is a list, guess_row and guess_col are indexes to retrieve value. to use indexes with lists, use square brackets


Do you still use the else:


yes, you do. I wast just saying where you went wrong

Please post your code using format


I add elif board guess_row, guess_col == "X": and it still didn't work.


you already had it? You have to modify it. board is a list, so you need the following syntax to update:

yourList[indexOne][indexTwo] = "new value"

list can be accessed by index using square brackets


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



What do I need for the else statment.


Please improve the quality of your question:

error message
explain what you do understand and what you don't

use markup for the code:

so indent shows