I need to pass a various amount of ships into the code but still be able to use their name when I am inside the hit_or_miss function. Is there a way to pass an arbitrary amount of parameters (as objects) but still access them specifically by name?
hit_or_miss(ship_1, ship_2, ship_3)
def hit_or_miss(*args):
# Everything from here on should go in your for loop!
# Be sure to indent four spaces!
ships_sunk = 0
for turn in range(4):
print "Turn", turn + 1
guess_row = int(raw_input("Guess Row:"))
guess_col = int(raw_input("Guess Col:"))
guess_loc = ((guess_row,guess_col))
# A correct guess congratulates and exits the game
if guess_loc in ship_1.location or \
guess_loc in ship_2.location or \
guess_loc in ship_3.location:
print "Congratulations! You sunk a battleship!"
ships_sunk += 1
board[guess_row - 1][guess_col - 1] = "H"