Skip to content
Merged
Prev Previous commit
Next Next commit
New structure of first paragraph in Text chapter.
  • Loading branch information
TommyUnreal committed Jul 23, 2023
commit 3edff8bb78e280299b227e25d6f740d15a1401c1
19 changes: 13 additions & 6 deletions Doc/tutorial/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,24 @@ and uses the ``j`` or ``J`` suffix to indicate the imaginary part

.. _tut-strings:

Texts
Text
-------
Comment thread
TommyUnreal marked this conversation as resolved.
Outdated

Different kinds of text have the type :class:`str`. This includes
characters "``!``", words "``rabbit``", names "``Paris``", sentences
"``Got your back.``", etc. "``Yay! :)``". They can be enclosed in single
quotes (``'...'``) or double quotes (``"..."``) with the same result [#]_.
``\`` can be used to escape quotes::
Python can manipulate text (represented by type :class:`str`, so called
Comment thread
TommyUnreal marked this conversation as resolved.
Outdated
"strings") as well as numbers. This includes characters "``!``", words
"``rabbit``", names "``Paris``", sentences "``Got your back.``", etc.
"``Yay! :)``". They can be enclosed in single quotes (``'...'``) or double
quotes (``"..."``) with the same result [#]_.

>>> 'spam eggs' # single quotes
'spam eggs'
>>> "Paris rabbit got your back :)! Yay!" # double quotes
Comment thread
TommyUnreal marked this conversation as resolved.
Outdated
'Paris rabbit got your back :)! Yay!'
>>> '1975' # digits and numerals enclosed in quotes are also strings
Comment thread
TommyUnreal marked this conversation as resolved.
Outdated
'1975'

To quote a quote, we need to "escape" it, by preceding it with ``\``::

>>> 'doesn\'t' # use \' to escape the single quote...
"doesn't"
>>> "doesn't" # ...or use double quotes instead
Expand Down