Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions Doc/tutorial/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,14 @@ This only works with two literals though, not with variables or expressions::

>>> prefix = 'Py'
>>> prefix 'thon' # can't concatenate a variable and a string literal
...
File "<stdin>", line 1
prefix 'thon'
^
SyntaxError: invalid syntax
>>> ('un' * 3) 'ium'
...
File "<stdin>", line 1
('un' * 3) 'ium'
^
SyntaxError: invalid syntax

If you want to concatenate variables or a variable and a literal, use ``+``::
Expand Down Expand Up @@ -320,10 +324,12 @@ Python strings cannot be changed --- they are :term:`immutable`.
Therefore, assigning to an indexed position in the string results in an error::

>>> word[0] = 'J'
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'str' object does not support item assignment
>>> word[2:] = 'py'
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'str' object does not support item assignment

If you need a different string, you should create a new one::
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
replaced ellipsis with correct error codes in tutorial chapter 3.