Fix code for Bad Aim, Battleship!


#1

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.


#2


Sorry about the order.


#3

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.


#4

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


#5

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