Battleship, printing


#1

My problem is much more basic; so bear with me.
I have two versions of the beginning of Battleship. In one I have 25 "O"s but not in a 5 x 5 matrix format and in the second I have a myriad of "O"s. Please help. I know that the print statement in the second code is indented but why should it present 75+ "O"s? Thank you

board = []
for i in range (0,5):
    board.append(["O"]*5)
print board 
    
board = []
for i in range (0,5):
    board.append(["O"]*5)
    print board

Battleship! keep getting error messages
#2

how we represent the data to the user (5x5 board) is not the same as how we store it (multi dimensional list), you will work on this in later exercise

it doesn't? its inside the for loop, so it will display the board while building it. So the first time.

its like buiding a fence. If we place 1 plank, we have 1 plank total. Then we place another plank so we have 2 planks total. But the way you get to the 75+ fields on your board is because you start counting all over again. In case of 2 planks, you count 3 (first one, then you add a second plank, and you count the first one again, giving you 3 planks), does that make sense? Every time you add, you start counting all over again, adding it to what you already counted. (would be a good way to make money :stuck_out_tongue: )


#3

Thank you Stetim. . That's kind. I have another post on Battleship where everything works but it says it doesn't. Oh well.


#4

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