QNA > P > Python 'Syntaxerror: Unexpected Character After Line Continuation Character' Occurring?

Python 'SyntaxError: unexpected character after line continuation character' occurring?

Your issue is that you miss understood the syntax of strings, you did this:

  1. 'Text '\n'another text' 
  2. ^~~^ 

As you can see here, To write strings, you can use single quotes or double quotes.

  1. "string" or 'string' 

And to add new lines:

  1. "String\n" 

What you did is that you ended the first string ‘Text ‘, then you put the newline character without strings quotes, then started a new string.

Python’s syntax doesn’t work this way, I know this is confusing, but take your time understanding it.

  1. "String \n New Line \n Another one \n Another one" 
  2. 'String \n New Line \n Another one \n Another one' 

As you can see here, you use the newline character inside (not outside) the string quotes, whether you use double or single quotes.

I recommend playing with it using the Python IDLE that comes with its package, and try to understand how this syntax works.

I hope this is helpful, Good luck!

Di Carbone Vanandel

In che ordine dovrei guardare Dragon Ball, Dragon Ball Kai, Dragon Ball Z e Dragon Ball GT? :: Qual è la differenza tra freemium e open source?
Link utili