Bad aim


#1

hi this code worked for me check it please i just can't under stand this line board[guess_row][guess_col]="X"
if guess_row == ship_row and guess_col == ship_col:
print "Congratulations! You sank my battleship!"
board[guess_row][guess_col]="X"
print_board(board)
elif guess_row not in range(5) or guess_col not in range(5):
print "Oops, that's not even in the ocean."
print_board(board)
else:
print "you missed my battleship"
board[guess_row][guess_col]="X"
print_board(board)


Bad aim
#2

guess_row and guess_col contain the guessed coordinates by the user, you use them to access the multi-dimensional list. if you have a list:

aList = ['a','b','c']

you can use use indexes:

aList[0]

if you have a list inside a list, you need two times [] to access the item, but the indexes can also be numbers stored in variable


#3

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