Feeds:
Posts
Comments

Archive for April 2nd, 2013

Strings is one or more combination of alphabet. Python will recognize double colon(“ ”) or single colon (‘ ‘) for string declaration.

For example, to declare ‘This is a string‘ as string, you can use double colon or single colon.

——————————-
>>> “This is a string”
‘This is a string’
>>> ‘This is a string’
‘This is a string’
>>>
——————————-

Very easy. How about to write Hii… I’m python. There is one single colon in the string.

You can’t write, ‘Hi.. I’m python’ because python will confuse to set the beginning and the end of the string because single colon in (I’m) will consider as end of string content.
——————————-
>>> “I’m python”
“I’m python”
>>> ‘I’m python’
SyntaxError: invalid syntax
>>>

But, with “double colon is fine.

——————————-
>>> “I’m python”
“I’m python”
——————————-

(more…)

Read Full Post »

Follow

Get every new post delivered to your Inbox.

Join 70 other followers