On Thu, 30 Jan 2014 13:26:16 +0000, Peter Clark wrote:

> 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.



-- 
Steven
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to