List and Its Operations
Learn what lists are and what operations can be performed on lists.
We'll cover the following...
Lists
A list in Python is just an ordered collection of heterogeneous item types and is dynamically mutable, meaning its size can change. List data structures support operations like add
, delete
, and insert
.
Press + to interact
## creating empty listsfruits = []## adding elements to listfruits.append('apple')fruits.append('banana')fruits.append('orange')print(fruits)
Key Pointers
- Python List
- Mutable
- Heterogeneous or homogeneous items, hence can be used as arrays
- Loosely typed
- Built-in into Python
- Generally comparatively slower than arrays, though the performance may vary in different use cases
Common PowerShell array and Python lists operations
Let’s discuss the common array operations.