# Python List Fundamentals: Syntax, Operations, and Examples

### Introduction

"*A* [*list*](https://www.tutorialsteacher.com/python/python-list) *in* [*Python*](https://ocw.mit.edu/courses/6-0001-introduction-to-computer-science-and-programming-in-python-fall-2016/1776670e271578eeb99fc25975f20586_MIT6_0001F16_Lec5.pdf) *is a data structure that stores a sequential collection of items, separated by commas. It is ordered, mutable, and offers various methods for manipulating content.* [*Lists*](https://www.programiz.com/python-programming/list) *are essential for* ***storing, processing, and manipulating data*** *in various programming tasks, enclosed in square brackets '****\[\]'****.*"

* [Lists](https://www.javatpoint.com/python-lists) are ordered, which means that each element's place inside the [list](https://blog.logrocket.com/working-lists-python/) is meaningful and preserved.
    
* [Lists](https://www.tutorialspoint.com/python/python_lists.htm) are changeable, which allows for the alteration of existing elements, the addition of new elements, and the removal of elements once the [list](https://www.includehelp.com/python/list-programs.aspx) has been created.
    
* <mark>I</mark>**<mark>ndexing, slicing, adding, extending, inserting</mark>**, and other operations are available for modifying the content of [lists](https://realpython.com/python-list/).
    

### Syntax of a [Python](https://www.scaler.com/topics/membership-operator-in-python/) [List](https://thepythonguru.com/python-lists/)

```python
my_list = [element1, element2, ..., elementN]
```

* `my_list`: This is the name you choose for your [list](https://www.askpython.com/python/list/python-list) variable.
    
* `element1, element2, ..., elementN`: Elements can be of any data type and are separated by commas.
    

Today's blog includes the following topics and examples to level up your [Python](https://www.tutorialspoint.com/python/membership_operators_example.htm) skills

* **Storing Different Types of Data in a** [**List**](https://www.scaler.com/topics/python/what-is-list-in-python/)
    
* **Creating** [**Lists**](https://www.scaler.com/topics/python/what-is-list-in-python/) **using range()** [**Function**](https://blog.bytescrum.com/functions-in-python-a-comprehensive-guide)
    
* [**Updating**](https://sparkbyexamples.com/python/update-list-element-in-python/) **the Elements of a** [**List**](https://www.programiz.com/python-programming/list#create)
    
* [**Concatenation**](https://www.w3schools.com/python/gloss_python_string_concatenation.asp) **of Two** [**Lists**](https://www.simplilearn.com/tutorials/python-tutorial/python-list)
    
* [**Repetition**](https://www.geeksforgeeks.org/python-element-repetition-in-list/) **of** [**Lists**](https://www.codecademy.com/resources/docs/python/lists)
    
* [**Membership**](https://www.w3schools.com/python/gloss_python_membership_operators.asp) **in** [**Lists**](https://pynative.com/python-lists/)**y**
    
* [**Aliasing**](https://runestone.academy/ns/books/published/thinkcspy/Lists/Aliasing.html) **and** [**Cloning**](https://brainly.in/question/21712040) [**Lists**](https://flexiple.com/python/list-of-lists-python)
    
* **Methods to Process** [**Lists**](https://builtin.com/data-science/python-list)
    
* **Finding the Biggest and Smallest Elements in a** [**List**](https://www.programiz.com/python-programming/list#add)
    
* [**Sorting**](https://docs.python.org/3/howto/sorting.html) **the** [**List**](https://www.programiz.com/python-programming/list#remove) **Elements**
    
* **Number of Occurrences of an Element in the** [**List**](https://www.openbookproject.net/thinkcs/python/english2e/ch09.html)
    
* **Finding Common Elements in Two** [**Lists**](https://www.learnpython.org/en/Lists)
    
* **Nested** [**Lists**](https://www.freecodecamp.org/news/how-to-make-a-list-in-python-declare-lists-in-python-example/) **as Matrices**
    
* [**List**](https://www.earthdatascience.org/courses/intro-to-earth-data-science/python-code-fundamentals/get-started-using-python/lists/) [**Comprehensions**](https://www.geeksforgeeks.org/comprehensions-in-python/)**.**
    

### Storing Different Types of Data in a [List](https://www.hackerrank.com/challenges/python-lists/problem)

[Python lists](https://www.w3schools.com/python/python_lists.asp) can store elements of different [data types](https://www.digitalocean.com/community/tutorials/python-data-types), including numbers, strings, and even other [lists](https://snakify.org/en/lessons/lists/).

```python
# list of integers
numbers = [1, 2, 3, 4, 5]
#list of strings
fruits = ["apple", "banana", "cherry"]
# mixed-type list
mixed = [1, "hello", 3.14, True]
# empty list
empty_list = []
```

* `numbers` is a [list](https://www.shiksha.com/online-courses/articles/lists-in-python/) of integers.
    
* `fruits` is a [list](https://www.toolsqa.com/python/python-lists/) of strings.
    
* `mixed` is a [list](https://codehs.com/tutorial/evelyn/lists-in-python) containing elements of different [data types](https://www.geeksforgeeks.org/python-data-types/).
    
* `empty_list` is an empty [list](https://www.tutorialkart.com/pdf/python/python-lists.pdf) with no elements.
    

<div data-node-type="callout">
<div data-node-type="callout-emoji">💡</div>
<div data-node-type="callout-text">Accessing elements in the <a target="_blank" rel="noopener noreferrer nofollow" href="https://levelup.gitconnected.com/list-vs-set-in-python-4ea183dfe20c" style="pointer-events: none">list</a> using indices, modifying the <a target="_blank" rel="noopener noreferrer nofollow" href="https://www.dummies.com/article/technology/programming-web-design/python/how-to-define-and-use-python-lists-264919/" style="pointer-events: none">list</a>, adding or removing elements, and performing various operations on it to manipulate your <a target="_blank" rel="noopener noreferrer nofollow" href="https://www.w3schools.com/python/python_datatypes.asp" style="pointer-events: none">data</a> as needed. <a target="_blank" rel="noopener noreferrer nofollow" href="https://pythonbasics.org/list/" style="pointer-events: none">Lists</a> are a fundamental <a target="_blank" rel="noopener noreferrer nofollow" href="https://www.programiz.com/python-programming/variables-datatypes" style="pointer-events: none">data structure </a>in <a target="_blank" rel="noopener noreferrer nofollow" href="https://prutor.ai/python-membership-and-identity-operators/" style="pointer-events: none">Python</a> and are extensively used in programming for various tasks.</div>
</div>

### Creating [Lists](https://blog.hubspot.com/website/python-lists) using range() Function

Make a [list](https://www.w3schools.com/python/python_ref_list.asp) of integers by using the **<mark>range()</mark>** function, which returns a series of numbers inside a given range.

```python
my_list = list(range(1, 6))
# Output: [1, 2, 3, 4, 5]
```

### Example 1: Generate a [list](https://www.geeksforgeeks.org/list-methods-in-python/) of dates for a calendar month

```python
days_in_month = list(range(1, 31))
    print(days_in_month)
```

The '**range(1, 31)**' function creates values ranging from **1** to **30**, indicating the days in a month.

### Updating the Elements of a [List](https://www.programiz.com/python-programming/methods/list)

*"*[*Lists*](https://intellipaat.com/blog/tutorial/python-tutorial/python-lists/) *in* [*Python*](https://libguides.ntu.edu.sg/python/membershipop) *are* ***mutable***\*, which implies that their items can be\* [*updated*](https://sparkbyexamples.com/python/update-list-element-in-python/) *by accessing them via their indices."*

```python
my_list = [1,12,42,34,67,77] 
my_list[2] = 42
```

### Example 2: An inventory management system for a store

It simulates selling 10 units of "**<mark>Widget A</mark>**" and [updates](https://www.tutorialspoint.com/updating-lists-in-python) its quantity

```python
# Initial list
inventory = [
    {"product": "Widget A", "quantity": 50},
    {"product": "Widget B", "quantity": 30},
    {"product": "Widget C", "quantity": 20}
]

sold_quantity = 10
product_to_update = "Widget A"

# Update sold product 
for item in inventory:
    if item["product"] == product_to_update:
        item["quantity"] -= sold_quantity

# updated inventory
for item in inventory:
    print(f"{item['product']}: {item['quantity']} in stock")
```

### [Concatenation](https://www.datacamp.com/tutorial/python-concatenate-strings) of Two [Lists](https://www.infoworld.com/article/3570480/how-to-work-with-the-python-list-data-type.html)

*"*[*Concatenation*](https://www.digitalocean.com/community/tutorials/python-string-concatenation) *of two* [*lists*](https://en.wikibooks.org/wiki/Python_Programming/Lists) *in* [*Python*](https://www.prepbytes.com/blog/python/membership-operator-in-python/) *includes joining the elements of one* [*list*](https://www.programiz.com/python-programming/methods/list) *with the components of another* [*list*](https://docs.python.org/3/tutorial/datastructures.html) *to generate a new, larger* [*list*](https://www.tutorialsteacher.com/python/list-methods)*."*

Combine two [lists](https://www.datacamp.com/tutorial/python-list-function) using the `+` operator.

```python
list1 = [1, 2, 3]
list2 = [4, 5, 6]
concatenated_list = list1 + list2
```

### Example 3: Different categories of products

```python
electronics = ["Laptop", "Smartphone", "Tablet"]
clothing = ["T-Shirt", "Jeans", "Jacket"]
# Concatenate 
all_products = electronics + clothing
# combined list 
print("Available Products:")
for product in all_products:
    print(product)
```

[Concatenating](https://www.geeksforgeeks.org/python-string-concatenation/) two [lists](https://www.dataquest.io/blog/tutorial-demystifying-python-lists/), '**electronics**' and '**clothes**', to create a new [list](https://www.analyticsvidhya.com/blog/2021/06/15-functions-you-should-know-to-master-lists-in-python/), '**all\_products**', which includes all items in the store.

### [Repetition](https://www.geeksforgeeks.org/python-element-repetition-in-list/) of [Lists](https://www.digitalocean.com/community/tutorials/understanding-lists-in-python-3)

* The `*` operator allows you to repeat a [list](https://mindmajix.com/python-sort) by specifying the number of times you want to [repeat](https://www.tutorialspoint.com/How-does-the-repetition-operator-work-on-a-tuple-in-Python) it.
    
* The resulting [list](https://www.w3schools.com/python/python_lists_methods.asp) will contain the elements of the original [list](https://www.softwaretestinghelp.com/python-list-functions/) [repeated](https://www.w3schools.in/python/repeat-string-in-python) as many times as specified.
    

```python
my_list = [0] * 3
# Output: [0, 0, 0]
```

### Example 4: Weekly application scheduling team of employees

```python
#  workweek
workweek = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"]
# schedule for 3 weeks
weekly_schedule = workweek * 3
# weekly schedule
print("Weekly Schedule:")
for day in weekly_schedule:
    print(day)
```

The `*` operator and `3` are used to [repeat](https://ww2.cs.fsu.edu/~nienaber/teaching/python/lectures/control-repetition.html) a `workweek` [list](https://towardsdatascience.com/python-list-methods-fa7c53010300) three times, creating a `weekly_schedule` [list](https://linuxhint.com/10_most_useful_python_list_methods/) covering three weeks, demonstrating the use of [list](https://www.digitalocean.com/community/tutorials/how-to-use-list-methods-in-python-3) [repetition](https://codeburst.io/concatenation-and-repetition-in-python-d3f843a683c8).

### [Membership](https://www.geeksforgeeks.org/python-membership-identity-operators-not-not/) in [Lists](https://www.educative.io/answers/what-is-a-python-list)

*"Check if an element is present in a* [*list*](http://www.compciv.org/guides/python/fundamentals/lists-mutability/) *using the* `in` *keyword."*

```python
my_list = [1, 4, 5, 7, 8, 3, 2]
if 3 in my_list:
    print("3 is in the list")
```

### [Aliasing](https://www.youtube.com/watch?v=IBa3XOvNBJM) and [Cloning](https://www.tutorialspoint.com/How-to-clone-or-copy-a-list-in-Python) [Lists](https://www.analyticsvidhya.com/blog/2021/07/all-the-basics-to-begin-with-python-lists/)

[**Alias**](https://www.geeksforgeeks.org/python-cloning-copying-list/)

* [Aliasing](https://www.youtube.com/watch?v=dDu_JzGOjHY) is the process of adding a new reference to an existing [list](https://www.youtube.com/watch?v=0yySumZTxJ0&ab_channel=Indently).
    
* In other words, two or more variables [link](https://www.pace.edu.in/img/course/COURSE%20MATERIAL_2ND_YEAR_18BT36_MODULE_4.pdf) to the same memory [list](https://www.tutorialspoint.com/list-methods-in-python) object.
    
* Changes to one variable affect the other variables referring to the same [list](https://builtin.com/data-science/python-list).
    

```python
list1 = [1, 2, 3]
list2 = list1 # Aliasing
list1[0] = 0
print(list2) # Output: [0, 2, 3]
```

[Cloning](https://www.slingacademy.com/article/cloning-a-list-in-python-deep-copy-shallow-copy/)

* [Cloning](https://www.gkindex.com/python-tutorial/python-lists-aliasing-cloning.jsp) is the process of constructing a new [list](https://geekflare.com/python-list-methods/) that contains the same entries as an existing [list](https://stackdiary.com/tutorials/python-list-methods/).
    
* This may be accomplished by the use of slicing, the **<mark>copy()</mark>** function, or the **<mark>list() </mark>** constructor.
    
* Changes made to the [cloned](https://www.stechies.com/clone-copy-list-python/) [list](https://learnpython.com/blog/python-list-methods/) do not affect the original [list](https://www.educba.com/list-method-in-python/).
    

```python
list1 = [1, 2, 3]
list2 = list1[:] # Cloning
list1[0] = 0
print(list2) # Output: [1, 2, 3]
```

### Example 5: To-do [list](https://www.knowledgehut.com/blog/programming/python-list-methods)

To create an [alias](http://pages.di.unipi.it/marino/python/Lists/Aliasing.html), assign `original_todo_list`, while [cloning](https://www.tutorialspoint.com/How-to-clone-or-copy-a-list-in-Python) the original [list](https://www.boardinfinity.com/blog/list-method-python/), changes to the [cloned](https://www.educative.io/answers/how-to-copy-a-list-in-python) [list](https://ipcisco.com/lesson/python-list-methods/) do not affect the original [list](https://ioflood.com/blog/python-list-methods/).

```python
original_todo_list = ["Buy groceries", "Pay bills", "Finish report"]
alias_todo_list = original_todo_list
# Modifying the alias list 
alias_todo_list.append("Call mom")
#clone
cloned_todo_list = list(original_todo_list)
# copy
cloned_todo_list.remove("Pay bills")

print("Original To-Do List:", original_todo_list)
print("Alias To-Do List:", alias_todo_list)
print("Cloned To-Do List:", cloned_todo_list)
```

### Methods to Process [Lists](https://www.edureka.co/blog/lists-in-python/)

[Python](https://www.slingacademy.com/article/cloning-a-list-in-python-deep-copy-shallow-copy/) provides several built-in methods to process and manipulate [lists](https://mindmajix.com/python/lists-concepts-in-python), including

* `append()`: Add an element to the end of a [list](https://sparkbyexamples.com/python/python-list-methods/).
    
* `extend()`: Extends a [list](https://www.youngwonks.com/blog/Python-List-Methods) with the elements from another iterable.
    
* `insert()`: Inserts an element at a specific index.
    
* `remove()`: Removes the first occurrence of a specified element.
    
* `pop()`: Removes and returns an element by index.
    
* `clear()`: Removes all elements from the [list](https://pythonguides.com/python-list-methods/).
    

### `append()`: Adds an element to the end of a [list](https://realpython.com/lessons/list-methods/).

```python
my_list = [1, 2, 3]
my_list.append(4)
print(my_list)  # Output: [1, 2, 3, 4]
```

The `append()` method adds an element to the end of a [list](https://realpython.com/python-lists-tuples/), like adding `4` to `my_list`, resulting in `[1, 2, 3, 4]`.

### `extend()`: Extends a [list](https://www.w3resource.com/python/list/index.php) with the elements from another iterable.

```python
list1 = [1, 2, 3]
list2 = [4, 5, 6]
list1.extend(list2)
print(list1)  # Output: [1, 2, 3, 4, 5, 6]
```

The `extend()` method adds elements from another iterable to a [list,](https://www.stat.berkeley.edu/~spector/extension/python/notes/node34.html) like `list1`, resulting in a single [list](https://www.codingninjas.com/studio/library/lists-methods) with the elements from `list2`.

### `insert()`: Inserts an element at a specific index.

```python
my_list = [1, 2, 3]
my_list.insert(1, 4)
print(my_list)  # Output: [1, 4, 2, 3]
```

The `insert()` method inserts an element at a specified index in a [list](https://ladderpython.com/lesson/list-functions-of-python-list-methods-of-python/), like `4` at index `1`, shifting existing elements accordingly.

### `remove()`: Removes the first occurrence of a specified element.

```python
my_list = [1, 2, 3, 2, 4]
my_list.remove(2)
print(my_list)  # Output: [1, 3, 2, 4]
```

The `remove()` method is used to remove the first occurrence of a specified element from a [list](https://runestone.academy/ns/books/published/thinkcspy/Lists/ListMethods.html), such as `2`.

### `pop()`: Removes and returns an element by index.

```python
my_list = [1, 2, 3, 4, 5]
element = my_list.pop(2)
print(element)  # Output: 3
print(my_list)  # Output: [1, 2, 4, 5]
```

The `pop()` method is used to remove and return an element at a specific index, as demonstrated in the example given.

### `clear()`: Removes all elements from the [list](https://www.toppr.com/guides/python-guide/references/methods-and-functions/methods/list/python-list-methods/).

```python
my_list = [1, 2, 3, 4, 5]
my_list.clear()
print(my_list)  # Output: []
```

The `pop()` method is used to remove and return an element at a specific index, as demonstrated in the example given.

### Finding the Biggest and Smallest Elements in a [List](https://pythonexamples.org/python-list-methods/)

To get the greatest and smallest members in a [list](https://holypython.com/beginner-python-lessons/lesson-6-python-lists/), use the '**<mark>max()'</mark>** and '***<mark>min()</mark>***<mark>'</mark> methods.

```python
largest = max(my_list)
smallest = min(my_list)
```

### Example 5: **Finding the Tallest**

```python
student_heights = [160, 175, 155, 180, 168, 162, 170]
tallest_student = max(student_heights)
shortest_student = min(student_heights)
print(f"The tallest student is {tallest_student} cm tall.")
print(f"The shortest student is {shortest_student} cm tall.")
#Output:
#The tallest student is 180 cm tall.
#The shortest student is 155 cm tall.
```

'**<mark>max(student_heights)</mark>**' returns the tallest student and'**<mark>min(student_heights)</mark>**' returns the smallest student from the'**student\_heights**' [list](https://blog.finxter.com/python-list-methods/).

### [Sorting](https://www.w3schools.com/python/ref_list_sort.asp) the [List](https://python.plainenglish.io/list-methods-in-python-236c4fa285a0) Elements

* The **sort()** method modifies a [list](https://er.yuvayana.org/list-methods-in-python/) in place, [sorting](https://www.geeksforgeeks.org/sorting-algorithms-in-python/) it in ascending order by default.
    
* The **sorted()** function takes an iterable as input and returns a new sorted [list](https://pythononeliners.com/wp-content/uploads/2020/05/Python-List-Methods-Cheat-Sheet.pdf), maintaining the original order.
    
* Custom [sorting](https://www.geeksforgeeks.org/sort-in-python/) can be done using the reverse and key arguments. Both methods are non-destructive.
    

```python
my_list.sort()
   # or
sorted_list = sorted(my_list)
```

### Example 6: [List](https://w3schoolsua.github.io/python/python_lists_methods_en.html#gsc.tab=0) of student records

```python
# name and exam score
student_records = [
    {"name": "Alice", "score": 92},
    {"name": "Bob", "score": 85},
    {"name": "Charlie", "score": 98},
    {"name": "David", "score": 78},
    {"name": "Eve", "score": 89},
]
#  sort() ascending order
student_records.sort(key=lambda x: x["score"])
#  sorted list
print("Sorted by exam score (ascending order):")
for record in student_records:
    print(f"{record['name']}: {record['score']}")
# sorted()  new sorted list descending order
sorted_records = sorted(student_records, key=lambda x: x["score"], reverse=True)
print("\nSorted by exam score (descending order):")
for record in sorted_records:
    print(f"{record['name']}: {record['score']}")
```

The **sorted()** method was utilized to sort student records in ascending order of exam scores, and a **new sorted** [**list**](https://careersknowledge.in/python-list-methods-and-list-operations/) in descending order, enabling easy identification of the highest-scoring students.

### Number of Occurrences of an Element in the [List](https://www.vtupulse.com/python-programs/list-methods-in-python/)

"*Count the occurrences of an element in a* [*list*](https://www.codewithharry.com/videos/python-tutorials-for-absolute-beginners-9/) *using the* `count()` *method.*"

```python
count = my_list.count(2)
```

### Finding Common Elements in Two [Lists](https://www.digitalocean.com/community/tutorials/understanding-lists-in-python-3)

*"Finding the common elements between two* [*lists*](https://www.toppr.com/guides/python-guide/tutorials/python-datatypes/list/python-list-with-examples/) *using* [*list*](https://copyassignment.com/python-list-methods-and-functions/) [*comprehension*](https://www.w3schools.com/python/python_lists_comprehension.asp) *or the* `intersection()` *method."*

```python
common_elements = [x for x in list1 if x in list2]
    # or
common_elements = list(set(list1).intersection(list2))
```

### Nested [Lists](https://cs.stanford.edu/people/nick/py/python-list.html) as Matrices

"*Create* [*lists*](https://www.ionos.com/digitalguide/websites/web-development/python-list/) *of lists, which are called nested* [*lists*](https://www.w3resource.com/python-exercises/list/)*."*

* Nested [lists](https://towardsdatascience.com/15-things-you-should-know-about-lists-in-python-c566792eca98) in [Python](https://www.studytonight.com/python-programs/python-program-to-cloning-or-copying-a-list) are [lists](https://www.codingninjas.com/studio/library/what-are-the-python-list-operations) of [lists](https://www.hackerearth.com/practice/python/working-with-data/lists/tutorial/), containing other [lists](https://python-reference.readthedocs.io/en/latest/docs/list/) as elements, used to represent complex [data structures](https://www.javatpoint.com/python-data-types) or tables where each element in the outer list is itself a list.
    
* To express matrices or multi-dimensional arrays, utilize layered [lists](https://learn.microsoft.com/en-us/training/modules/intro-python-lists/).
    

```python
matrix = [
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9]
]
element = matrix[1][1]
print(element)  # Output: 5
```

The code selects the second inner list from the second inner [list](https://www.tutsmake.com/python-3-list-built-in-functions-methods/), **<mark>'[4, 5, 6]'</mark>**.

Nested [lists](https://www.educba.com/python-lists-methods/) are versatile and can be used to represent various [data](https://www.tutorialspoint.com/python/python_data_types.htm) structures, such as **<mark>tables, grids, or hierarchical </mark>** [**<mark>data</mark>**](https://www.softwaretestinghelp.com/python-data-types/)**<mark>.</mark>** They are commonly used in applications involving matrices, game boards, and more complex [data](https://www.analyticsvidhya.com/blog/2021/05/data-types-in-python/) structures.

### [List](https://www.jquery-az.com/python-list-12-examples-to-learn-with-built-in-methods/) [Comprehensions](https://realpython.com/list-comprehension-python/)

*"*[*List*](https://blog.hubspot.com/website/python-list-functions) [*comprehensions*](https://www.scaler.com/topics/python/comprehensions-in-python/) *provide a concise way to create* [*lists*](https://www.knowledgehut.com/tutorials/python-tutorial/python-lists-tuples) *based on existing* [*lists*](https://www.afternerd.com/blog/python-lists-for-absolute-beginners/)*."*

```python
numbers = [1, 2, 3, 4, 5]
# comprehension 
odd_numbers = [x for x in numbers if x % 2 != 0]
print(odd_numbers)[1, 3, 5]
#output
[1, 3, 5]
```

[Comprehensions](https://www.tutorialspoint.com/comprehensions-in-python) in [Python](https://www.edureka.co/blog/membership-operators-in-python) allow for the creation of new [lists](https://365datascience.com/tutorials/python-tutorials/lists-python/) by applying an expression to each item in an existing iterable and optionally filtering the items based on a condition.

<details data-node-type="hn-details-summary"><summary>Summary</summary><div data-type="detailsContent"><a target="_blank" rel="noopener noreferrer nofollow" href="https://developers.google.com/edu/python/lists" style="pointer-events: none">Python lists</a> are essential data structures in programming, offering various operations and use cases. They can be created using the <code>range()</code> function, <a target="_blank" rel="noopener noreferrer nofollow" href="https://www.onlinetutorialspoint.com/python/different-ways-to-update-python-list.html" style="pointer-events: none">updated</a> using indices, combined using the <code>+</code> operator, <a target="_blank" rel="noopener noreferrer nofollow" href="https://www.linkedin.com/pulse/python-programming-beginners-part-4-repetitive-loops-shrivastava/" style="pointer-events: none">repeated </a>using the <code>*</code> operator, and aliased and <a target="_blank" rel="noopener noreferrer nofollow" href="https://stackoverflow.com/questions/2612802/how-do-i-clone-a-list-so-that-it-doesnt-change-unexpectedly-after-assignment" style="pointer-events: none">cloned</a> using slicing or the <code>list()</code> constructor. They can store different types of data, create nested <a target="_blank" rel="noopener noreferrer nofollow" href="https://docs.python.org/3/tutorial/datastructures.html" style="pointer-events: none">lists</a> for complex structures, and use <a target="_blank" rel="noopener noreferrer nofollow" href="https://pythonexamples.org/python-list/" style="pointer-events: none">list</a> <a target="_blank" rel="noopener noreferrer nofollow" href="https://www.programiz.com/python-programming/list-comprehension" style="pointer-events: none">comprehensions</a> for filtering and transformation.</div></details>
