In Python, a list is a built-in data structure that allows you to store multiple items in a single variable.

You create a list by placing items inside square brackets [], separated by commas.

my_list = ["apple", "banana", "cherry"]

In Python, you can store different types of data in a single list.

mixed_list = [1, "apple", 3.14, True]

Key Differences: Lists vs Strings

Lists can be changed (mutable), and strings cannot (immutable).

snapedit_1723878677927.jpeg

  1. Accessing Items: Use indices to access elements (zero-based index).
items = ["apple", "banana", "cherry"]
print(items[0]) 

**# Output: 'apple'**

items = ["apple", "banana", "cherry"]
print(items[-1])

**# Output: 'cherry'**
  1. Slicing: Use slicing to get a subset of the list.