- Hands-On Penetration Testing with Python
- Furqan Khan
- 252字
- 2021-07-02 14:13:50
List types
Python does not have array types, but instead offers the list data type. Python lists also fall under the category of sequences and offer a wide range of functionalities. Coming from a Java, C, or C++ background, you are likely to find that Python lists are slightly different from the arrays and list types offered by these languages. In C, C++, or Java, an array is a collection of elements of similar data types, and this is also the case for Java array lists. This is different in the case of Python. In Python, a list is a collection of elements that can be of either homogeneous and heterogeneous data types. This is one of the features that makes Python lists powerful, robust, and easy to use. We also don't need to specify the size of a Python list when declaring it. It can grow dynamically to match the number of elements it contains. Let's see a basic example of using lists:

Lists in Python start from index 0 and any item can be accessed on the basis of indices, as shown in the preceding screenshot. The preceding list is homogeneous, as all the elements are of string type. We can also have a heterogeneous list, as follows:

For now, we are printing the list elements manually. We can very easily iterate over them with loops instead, and we will explore that later on. For now, let's try to understand which operations can be performed on list structures in Python.
- C++面向對象程序設計(第三版)
- Xcode 7 Essentials(Second Edition)
- CKA/CKAD應試教程:從Docker到Kubernetes完全攻略
- GameMaker Programming By Example
- iOS應用逆向工程(第2版)
- AutoCAD VBA參數化繪圖程序開發與實戰編碼
- Building an RPG with Unity 2018
- C語言程序設計
- Machine Learning in Java
- Fastdata Processing with Spark
- MyBatis 3源碼深度解析
- UX Design for Mobile
- SSH框架企業級應用實戰
- Building UIs with Wijmo
- Bitcoin Essentials