For this program, I am creating a two-player Battleship! game. At the end of the program, I ask the user to put in coordinates for his ship. Then, I ask the user for other coordinates if the coordinates are not in the ocean.
When I run the program, I expected that the program would exit once the user puts in coordinates like (3, 4), but the code keeps asking the user for other coordinates. Is it a problem with my code?
my_ship_x = raw_input("X-cordinate for your ship: ") my_ship_y = raw_input("Y-cordinate for your ship: ") print my_ship_x, ", ", my_ship_y print len(my_board) print len(my_board) while (my_ship_y < 0 or my_ship_y >= len(my_board) or \ my_ship_x < 0 or my_ship_x >= len(my_board)):