Data Structures

Working with Python Lists and Dictionaries

Organized data structure concept
Python Lists and Dictionaries
Lists and dictionaries are two of the most powerful data structures in Python. A list is an ordered collection that can hold any type of data. You create one with square brackets: fruits = ["apple", "banana", "cherry"]. Lists are mutable, meaning you can change them after creation. You can add items with .append(), remove with .remove(), and access items by their index. Python indexes start at 0, so fruits[0] gives "apple". Dictionaries are unordered collections of key-value pairs. They are created with curly braces: person = {"name": "John", "age": 30}. You access values using keys: person["name"]. Dictionaries are incredibly useful for storing structured data. You can nest lists inside dictionaries and vice versa. For example, you could have a dictionary where each key is a student name and the value is a list of their grades. Understanding how to iterate over these structures is also important. You can loop through a list with for item in list: and through a dictionary with for key, value in dict.items():. These structures are the backbone of data manipulation in Python. Practice by creating a to-do list application where tasks are stored in a list or a contact book where contacts are stored in a dictionary.
1,599
Views
200
Words
1 min read
Read Time
Apr 2025
Published
← All Articles 📂 Data Structures