Battleship


#1

I am confused in this level as what actually happens? and also one parameter "board" can be assigned to multiple functions? If possible then how python access that parameter in different functions??

def random_row(board):
for row in board:
return randint(0,len(row) -1)

def random_col(board):
for col in board:
return randint(0,len(col) -1)

No idea of what's happening.


#2

we our going to pick coordinates for our ship to hide, which the user has to guess.

yea, function parameters are just local variables (they only exist inside the function) so you can use the same parameter name multiply times for different functions.

since we only want one coordinate on the board, we don't need a loop.


#3

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