To your Battle Stations!


#1

This is not needed with regards to passing the lesson but:
If the user types letter the game breaks (due to raw_input(int()), I was thinking I could put an if statement for if guess_row.isalpha() or guess_col.isalpha():
print "Oops, that's not even a number! Please re-start game."
break
as allowing the string to go through breaks it. Is there a way to ensure the string isn't carried through without simply cutting off the loop?
Thanks in advance


#2

Update: I change the original input to (only doing guess_row for speed):

guess_row = (raw_input("Guess_Row")

if guess_row.isalpha():
    print "Oops that's not even a number!  You lose a turn!"

turn += 1
print "Turn %r" %(turn)

else:
    guess_row = int(guess_row)

Then indented everything else. However, an empty placeholder also breaks the game. I know in VBA there is an isempty function, is there a similar one in python?
Thanks


#3

Hello, @ascottishpenguin!
If you're still having problems with your code, post it here so we can take a look at it.
And regarding the isempty function, as far as I know there's no such function, unless you create it by youself.

You can wheter check if a list, string or dictionary is empty by using the function len().

Best regards,
g4be