The following operators can be applied to sequence types, including strings, lists, and tuples:
|s + r||Concatenation|
|s * n, n * s||Makes n copies of s, where n is an integer|
|s % d||String formatting (strings only)|
|x in s, x not in s||Membership|
|for x in s:||Iteration|
The + operator concatenates two sequences of the same type. The s * n operator makes n copies of a sequence. However, these are shallow copies that replicate elements by reference only. For example, consider the following code:
a = [3,4,5] # A list b = [a] # A list containing a c = 4*b # Make four copies of b # Now modify a a = -7 # Look at c print ...