Lists in Python
In Python, a list is a versatile and widely-used data structure that allows you to store an ordered collection of items. Lists are mutable, meaning you can modify their contents after creation. Here's an overview of how to work with lists in Python: --- ### **1. Creating a List** You can create a list by enclosing elements in square brackets `[]`, separated by commas. ```python # Example of a list my_list = [1, 2, 3, 4, 5] print(my_list) # Output: [1, 2, 3, 4, 5] ``` Lists can contain elements of different data types, including numbers, strings, other lists, or even mixed types.