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

Indexing, slicing, and matrices

List indices work the same way as string 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 list named cities and we will see the index operations:

cities = ['Mumbai', 'Bangalore', 'Chennai', 'Pune']

主站蜘蛛池模板: 宿州市| 芦溪县| 南郑县| 阿拉尔市| 白银市| 师宗县| 象山县| 米脂县| 德安县| 田林县| 桐庐县| 玛纳斯县| 湘潭市| 繁峙县| 东莞市| 淮滨县| 和田市| 义马市| 镇康县| 集贤县| 四川省| 武邑县| 涟源市| 吕梁市| 万源市| 扬中市| 怀柔区| 会理县| 宁津县| 清河县| 岗巴县| 兴仁县| 信阳市| 乌拉特前旗| 沾益县| 北票市| 台中市| 衡水市| 马尔康县| 梁山县| 曲周县|