Good job! For now, let’s store coordinates for the ship in the variables ship_row
and ship_col
. Now you have a hidden battleship in your ocean! Let’s write the code to allow the player to guess where it is.
number = raw_input("Enter a number: ") if int(number) == 0: print "You entered 0"
raw_input
asks the user for input and returns it as a string. But we’re going to want to use integers for our guesses! To do this, we’ll wrap the raw_input
s with int()
to convert the string to an integer.
Instructions
Create a new variable called guess_row
and set it to int(raw_input("Guess Row: "))
.
Create a new variable called guess_col
and set it to int(raw_input("Guess Col: "))
.
Click Run and then answer the prompts by typing in a number and pressing Enter (or Return on some computers).