end quote help for a newbie

P

Peter Clark

There is probably an easy solution to this – but I have not found it.

Trying to terminate a literal in a print statement (from the
tutorial).

The literal should be enclosed in double quotes “ “

the initial double quote seems to be OK (if I use a different character it
flags it) but the ending is flagged as invalid syntax..  I have tried changing my
keyboard from UK to USA, without any effect, and tried adding a space after the
final double quote,

thanksfor any assistance,

peter
 
S

Steven D'Aprano

There is probably an easy solution to this – but I have not found it.

Trying to terminate a literal in a print statement (from the tutorial).

I don't understand the problem. Perhaps if you show us what you have
tried, and the error you get? Please copy and paste both your code and
the full error, from the first line starting with "Traceback" and ending
with the error message.

Regardless of using print or not, you terminate strings with a matching
quotation mark. If you start the string with a double-quote, you
terminate it with the same double-quote. If you use a single-quote, the
same applies. These two are okay:

"Double quote"
"Single quote"

But not this:

"Mixed quotes'
'Mixed quotes"

The literal should be enclosed in double quotes “ “

What editor are you using? If you are typing your code in Microsoft
Office, you're going to have a bad time. At the very least, you need to
turn "Smart Quotes" off. Python will not accept curly quotes such as ‘’
or Ҡor any of the various other quotation marks, only plain old
typewriter quotation marks ' and " (actually, these are foot and inch
marks, but everyone treats them as if they were quotation marks).

the initial double quote seems to be OK (if I use a different character
it flags it) but the ending is flagged as invalid syntax.  I have tried
changing my keyboard from UK to USA, without any effect, and tried
adding a space after the final double quote,

UK or USA keyboard won't make any difference. You need to use an ordinary
text editor (or better still, a programmer's text editor) but not a word
processor such as Word. If you must use Word, disable "Smart Quotes".
That will avoid at least one source of problems.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,001
Messages
2,570,255
Members
46,853
Latest member
GeorgiaSta

Latest Threads

Top