>>> 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 ``+``::
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::