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

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

 

主站蜘蛛池模板: 昆山市| 海丰县| 鄂州市| 新竹县| 阿图什市| 团风县| 德阳市| 大同市| 澄江县| 东平县| 凉城县| 徐汇区| 沙坪坝区| 正宁县| 多伦县| 富源县| 承德县| 鸡西市| 尼玛县| 昌图县| 湘西| 奈曼旗| 高雄县| 教育| 黄平县| 泾阳县| 黄大仙区| 额尔古纳市| 商都县| 盘山县| 梅州市| 扶绥县| 永嘉县| 密山市| 新营市| 土默特左旗| 沂水县| 富锦市| 广南县| 永春县| 泾川县|