- 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.
- Android項(xiàng)目開發(fā)入門教程
- Go語言高效編程:原理、可觀測性與優(yōu)化
- jQuery EasyUI網(wǎng)站開發(fā)實(shí)戰(zhàn)
- C語言程序設(shè)計(jì)教程(第2版)
- Web Development with Django Cookbook
- AngularJS深度剖析與最佳實(shí)踐
- MySQL數(shù)據(jù)庫管理與開發(fā)(慕課版)
- 精通Python自動化編程
- 持續(xù)輕量級Java EE開發(fā):編寫可測試的代碼
- Hands-On Nuxt.js Web Development
- SEO教程:搜索引擎優(yōu)化入門與進(jìn)階(第3版)
- Continuous Delivery and DevOps:A Quickstart Guide Second Edition
- 嵌入式C編程實(shí)戰(zhàn)
- 安卓工程師教你玩轉(zhuǎn)Android
- MongoDB Cookbook