官术网_书友最值得收藏!

Indexing, slicing, and matrices

Tuple indices work the same way as list indices. Values can be accessed using index. If you try to read or write an element that does not exist, you get IndexError. If an index has a negative value, it counts backward from the end of the list. 

Now, we will create a tuple named cities and perform some index operations:

cities = ('Mumbai', 'Bangalore', 'Chennai', 'Pune')

 

主站蜘蛛池模板: 彭阳县| 甘孜县| 鄄城县| 建平县| 房产| 无棣县| 石门县| 天峻县| 盱眙县| 保靖县| 阳东县| 华宁县| 白城市| 宝丰县| 壤塘县| 岳阳市| 临邑县| 临沭县| 改则县| 安溪县| 宿松县| 谢通门县| 新安县| 津南区| 金溪县| 泊头市| 河南省| 壤塘县| 杭锦后旗| 会泽县| 黑山县| 铅山县| 砀山县| 泽普县| 渭源县| 岱山县| 汾阳市| 台江县| 龙山县| 双辽市| 长海县|