Friday, April 13, 2018

Basic Tuples Operations


Basic Tuples Operations

Tuples respond to the + and * operators much like strings; they mean concatenation and repetition here too, except that the result is a new tuple, not a string.

In fact, tuples respond to all of the general sequence operations we used on strings in the prior chapter −

Python Expression
Results
Description
len)
3
Length
 + 
Concatenation
 * 4
Repetition
3 in 
True
Membership
for x in : print (x),
1 2 3
Iteration