|
- >>> tuple1 = [(2,3),(4,5)]
- >>> tuple1[0]
- (2, 3)
- >>> tuple1[0][0]
- 2
- >>> tuple1[0][2]
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- IndexError: tuple index out of range
- >>> tuple1[0][1]
- 3
- >>> tuple1[2][2]
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- IndexError: list index out of range
- >>> tuple2 = tuple1+[(3)]
- >>> tuple2
- [(2, 3), (4, 5), 3]
- >>> tuple2[2]
- 3
- >>> tuple2[2][0]
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- TypeError: 'int' object is not subscriptable
复制代码 |
|