Member-only story
Python Programming
Python
Python3
Day 5: Python Syntax: Basic Concepts — List in detail
3 min readFeb 15, 2025
Python in 30 Days: A Practical and Theoretical Approach for Beginner.
A list is one of the most commonly used data structures in Python.
Press enter or click to view image in full size![]()
It is a collection of ordered, mutable (changeable), and heterogeneous elements.
Lists allow you to store multiple items in a single variable.
Lists are defined by square brackets
[].
Characteristics of Lists:
- Ordered: The items in a list have a specific order, and this order is maintained.
- Mutable: You can change the elements in a list (add, remove, modify).
- Heterogeneous: A list can store elements of different data types (e.g., integers, strings, or even other lists).
SYNTAX
list_name = [element1, element2, element3, ...]Example of List in Python
- Creating a List
# Creating a List
fruits = ["apple", "banana", "cherry", "orange"]2. Accessing elements by index (starting from 0)
print(fruits[0]) # Output: apple
print(fruits[2]) # Output: cherry