Bad aim


#1

Why this code will start always and not depends if we insert correct row and col values
if guess_row is not range(5) or guess_col is not range(5):
print "Oops, that's not even in the ocean."

but
if (guess_row < 0 or guess_row > 4) or (guess_col < 0 or guess_col > 4):
print "Oops, that's not even in the ocean."

works?

Second thing is that we need to add if statement before we add row and column to board because if we insert row 7 it gives error? But it is not in instructions....


#2

we can use in keyword to check if a value is in a list or string, not is keyword

to check if something is not in list or string we can use not in


#3

ok thanks I just didnt know correct spelling
if guess_row not in range(5) or guess_col not in range(5):

works


#4

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