Bad aim battleship


#1

if guess_row == ship_row and guess_col == ship_col:
print("congratulations! you sank my battleship!")
else:
if guess_row not in range(5) or guess_col not in range(5):

    print("Oops that's not even in the ocean")   
else:
    print("You missed my battleship!")
board[guess_row][guess_col] = "X"

print_board(board)

print ship_row
print ship_col

this is as per instructions, but i would have also thought of coding this block of statement after the raw_input to check whether the input is within range._after the input

it would have been
if guess_row not in range(5) or guess_col not in range(5):
print("Oops that is not even in the ocean kindly enter the correct input")
( is it possible to iterate the same to the line of code which again asks for the input ??)
iterate till condition is satisfied

something like

for guess_row not in range(5) or guess_col not in range(5):
print "Oops that is not even in the ocean kindly enter the correct input"
guess_row = int(raw_input("Guess Row:"))
guess_col = int(raw_input("Guess Col:"))

thank you..!!


#2

suitcase = []
suitcase.append("sunglasses")

Your code here!

suitcase.append("bathsoap")
suitcase.append("shampoo")
sutcase.append("paste")

list_length = %s suitcase # Set this to the length of suitcase

print "There are %d items in the suitcase." % (list_length)
print suitcase

can anybody suggest what is the correct code?????


#3

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