Data Structures in Python

Python provides several built-in data structures such as lists, tuples, sets, and dictionaries.

1. Lists

A list is a collection of ordered items, and it allows duplicate elements.

Example:

my_list = [1, 2, 3, 4, 5]

2. Tuples

A tuple is similar to a list, but it is immutable (cannot be modified after creation).

Example:

my_tuple = (1, 2, 3, 4, 5)

3. Sets A set is an unordered collection of unique items.

Example:

my_set = {1, 2, 3, 4, 5}

4. Dictionaries

A dictionary is a collection of key-value pairs.

Example:

my_dict = {"name": "Alice", "age": 30, "city": "New York"}