Fix code for Bad Aim, Battleship!


For line 33, I get a error:

File "python", line 33
** if guess_row not in range(5) or \ guess_col not in range(5):**
** ^**
SyntaxError: unexpected character after line continuation character
from random import randint

How do I fix it? I am really unsure how to integrate \ (continuation character) into the code. I know what it is, but don't know how to place it.


Sorry about the order.


When the continuation character is used, there should be only one character following it, a newline, \n. In other words, insert a hard return in the code

    if guess_row not in range(5) or \
guess_col not in range(5):

Notice I didn't indent the next line? A tab, or more white space may cause the same error. You can try it with indentation to match the start of the line, but if your get an error, restore it back to this way.


Thank you very much. It worked. Also, what is the name of the group of \ followed by a letter (like \n)?


The group is called escape sequences. Even by itself, we see that the escape character alone is defined as continuation.