Python Lessons – 1.7 Operations on Strings

Python Lessons - 1.7 Operations on strings

String concatenation

Perhaps the most used operation on strings is the concatenation of two or more strings. In other words, it is often necessary to combine several strings to form longer sentences.

>>> "Salt" + " & " + "Pepper"
'Salt & Pepper'

Repetition of strings

Strange, but strings can also be played repeatedly repeatedly, using the multiplication operator *.

>>> "10" * 4
'10101010'
>>> "Doo" * 2
'DooDoo'

⇐ Go to Python Lesson 1.6 – Input and output

Go to Python Lesson 1.8 – Type conversion ⇒

Leave a Reply