Tuple built-in functions
Python tuple contains the following built-in functions
No. | Method and Description | Examples |
---|---|---|
1 | len (tuple) calculates the number of tuples of elements. |
>>> tuple1 = ('Google', 'Runoob', 'Taobao') >>> len(tuple1) 3 >>> |
2 | max (tuple) Returns the maximum element tuple. |
>>> tuple2 = ('5', '4', '8') >>> max(tuple2) '8' >>> |
3 | min (tuple) returns the minimum value tuple element. |
>>> tuple2 = ('5', '4', '8') >>> min(tuple2) '4' >>> |
4 | tuple (seq) converts a list of tuples. |
>>> list1= ['Google', 'Taobao', 'Runoob', 'Baidu'] >>> tuple1=tuple(list1) >>> tuple1 ('Google', 'Taobao', 'Runoob', 'Baidu') |