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

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')

 

主站蜘蛛池模板: 普兰县| 金华市| 昌平区| 云霄县| 陈巴尔虎旗| 武宁县| 宁德市| 河间市| 雷山县| 新巴尔虎右旗| 右玉县| 沙湾县| 龙江县| 云南省| 长岛县| 楚雄市| 武穴市| 抚松县| 恩平市| 博客| 洛阳市| 榆中县| 志丹县| 津南区| 开平市| 吉木萨尔县| 垦利县| 南郑县| 密山市| 社旗县| 林芝县| 左贡县| 满洲里市| 辰溪县| 龙南县| 公安县| 揭东县| 韶关市| 武隆县| 湖南省| 雷波县|