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

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

主站蜘蛛池模板: 大兴区| 收藏| 应城市| 赤城县| 肃北| 和静县| 通辽市| 三都| 临汾市| 邢台县| 平凉市| 平和县| 南康市| 大城县| 太湖县| 方正县| 莒南县| 泸溪县| 安福县| 兴宁市| 陆川县| 克什克腾旗| 扬州市| 新晃| 娱乐| 巴塘县| 汕头市| 乌拉特前旗| 丹阳市| 衡南县| 陇川县| 康平县| 富蕴县| 嘉定区| 玛曲县| 寿宁县| 通许县| 霍城县| 西充县| 天镇县| 东明县|