- Mastering Python Scripting for System Administrators
- Ganesh Sanjiv Naik
- 63字
- 2021-07-02 14:00:22
Accessing values in lists
We can access the values from a list by using index values. We will specify the index number in [ and ]. Index starts from 0. Refer to the given example:
#!/usr/bin/python3
cities = ['Mumbai', 'Bangalore', 'Chennai', 'Pune']
numbers = [1, 2, 3, 4, 5, 6, 7 ]
print (cities[0])
print (numbers[1:5])
Output:
Mumbai
[2, 3, 4, 5]
推薦閱讀
- Learn TypeScript 3 by Building Web Applications
- 案例式C語言程序設計
- Java面向對象思想與程序設計
- Java從入門到精通(第5版)
- JSP開發案例教程
- Reactive Android Programming
- 從Excel到Python:用Python輕松處理Excel數據(第2版)
- Learning Hunk
- 機器學習微積分一本通(Python版)
- Drupal 8 Development:Beginner's Guide(Second Edition)
- 快樂編程:青少年思維訓練
- Android智能手機APP界面設計實戰教程
- Mapping with ArcGIS Pro
- 基于Docker的Redis入門與實戰
- Visual Basic 開發從入門到精通