Chapter 2: Basic data types

Strings

face Josiah Wang

Strings (str) are a sequence of characters.

In Python, you surround string literals with either 'single quotes', "double quotes", '''triple quotes''' or """triple double-quotes""".

Try these:

>>> 'Is Python that easy?'
'Is Python that easy?'
>>> "Is Python that easy?"
'Is Python that easy?'
>>> '''Is Python that easy?'''
'Is Python that easy?'
>>> """Is Python that easy?"""
'Is Python that easy?'

All four are equivalent. So 'my string' is identical to "my string".

Note #1: There is no char type in Python. Just use str (of length 1)!