Clickable hyperlinks
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Tue Jan 3 20:43:46 EST 2017
On Wednesday 04 January 2017 15:46, Deborah Swanson wrote:
> Steven D'Aprano wrote, on January 03, 2017 8:04 PM
[...]
>> Of course you have to put quotes around them to enter them in
>> your source code.
>> We don't expect this to work:
>>
>> print(Hello World!)
>>
>>
>> you have to use a string literal with quotes:
>>
>> print('Hello World!')
>>
>>
>> Same for all of the above.
> I didn't try printing them before, but I just did. Got:
>
>>>> print([Example](http://www.example.com)
>
> SyntaxError: invalid syntax (arrow pointing at the colon)
You missed the part where I said you have to put them in quotes.
Like any other string in Python, you have to use quotation marks around it for
Python to understand it as a string. None of these things will work:
print( Hello World! )
print( What do you want to do today? )
print( 3 2 1 blast off )
print( http://www.example.com )
This isn't specific to print. This won't work either:
message = Hello World!
In *all* of these cases, you have to tell Python you're dealing with a string,
and you do that with quotation marks:
message = "Hello World!"
print( 'What do you want to do today?' ) count_down = '3 2 1 blast off'
url = 'http://www.example.com'
--
Steven
"Ever since I learned about confirmation bias, I've been seeing it everywhere."
- Jon Ronson
More information about the Python-list
mailing list