Why dose have an unexpected character after line continuation charcter

if (i is 2 or 3 == 0, \ (“disvible by 2 and 3”)):
print (“{} it disvible by 2 and 3”.format(i))

The \ should be at the end of the line. Is there a space after it instead?

Also, please wrap any code in backticks to preserve the formatting:

```
if True:
    print('Hello world!')
```

Please post your code between “code fences”, three backticks on a line of their own, like this:

```
code goes here
```

You can also use three tildes ~~~.

In this case, your code is this:

if (i is 2 or 3 == 0, \\ ("disvible by 2 and 3")):
  print ("{} it disvible by 2 and 3".format(i))

Try writing this instead:

if i % 2 == 0 or i % 3 == 0:
    print ("{} is divisible by 2 or 3".format(i))

if i % 6 == 0:
    print ("{} is divisible by 2 and 3".format(i))

Matthew’s mentioned that the \ line continuation character must be the
last character on a line. So the second \ is what it is complaining
about if you have some error text which actually says “unexpected
character after line continuation charcter”.

But the error itself is probably misleading you, because I expect that
you do not intend to use a line continuation character at all. Python’s
just seen that character and itself been misled about your code.

It is usually best to include any erorr messages in full, pasted
directly into the message as text between triple backticks:

 ```
 your error
 messages
 go here
 ```

and the same with your code. This preserves the formatting.

Let’s look at your code:

 if (i is 2 or 3 == 0, \\ ("disvible by 2 and 3")):
     print ("{} it disvible by 2 and 3".format(i))

It seems to me that you intend to test that the value in i is
divisible by 2 and is also divisible by 3. The way to test
divisibility is usually to look at the remainder of a division, which is
supplied by the % operator. Examples:

 >>> 3 % 3
 0
 >>> 5 % 3
 2
 >>> i = 6
 >>> i % 3
 0
 >>> i % 3 == 0
 True
 >>> if i % 3 == 0:
 ...     print("yes")
 ...
 yes

Does this help you with both the tests and the syntax (punctuation)?

Cheers,
Cameron Simpson cs@cskk.id.au