December 2000
Intermediate to advanced
816 pages
16h 57m
English
Object and sequence operators and built-in functions act the exact same way toward tuples as they do with lists. You can still take slices of tuples, concatenate and make multiple copies of tuples, validate membership, and compare tuples:
>>> t = (['xyz', 123], 23, -103.4)
>>> t
(['xyz', 123], 23, -103.4)
>>> t * 2
(['xyz', 123], 23, -103.4, ['xyz', 123], 23, -103.4)
>>> t = t + ('free', 'easy')
>>> t
(['xyz', 123], 23, -103.4, 'free', 'easy')
>>> 23 in t 1 >>> 123 in t 0 >>> t[0][1] 123 >>> t[1:] (23, -103.4, 'free', 'easy')
>>> str(t) (['xyz', 123], ...
Read now
Unlock full access