Sitemap
Burra Chandana

Burra Chandana

Python Lists and Tuples

2 min readJul 19, 2026

--

Introduction

Python provides several built-in data types to store collections of data. Two of the most commonly used are Lists and Tuples. Both allow you to store multiple values in a single variable, making programs more organized and efficient.

Although lists and tuples look similar, they have an important difference:

Lists are mutable (can be changed).

Tuples are immutable (cannot be changed after creation).

Understanding when to use a list and when to use a tuple is an essential Python skill.

What is a List?

A List is an ordered collection of items enclosed in square brackets [ ].

Lists can store:

Numbers, Strings, Boolean values, Objects, Mixed data types

Syntax

list_name = [item1, item2, item3]

Example:

fruits = [“Apple”, “Banana”, “Mango”]

print(fruits)

output:

[‘Apple’, ‘Banana’, ‘Mango’]

properties of Lists

Ordered

Mutable (can be modified)

Allows duplicate values

Can store different data types

Supports indexing and slicing

Example:

data = [10, “Python”, 3.14, True]

print(data)

Output:

[10, ‘Python’, 3.14, True]

Accessing List Elements

Using positive Indexing

fruits = [“Apple”, “Banana”, “Mango”]

print(fruits[0])

print(fruits[2])

Output:

Apple

Mango

Using Negative Indexing

print(fruits[-1])

output:

Mango

List Slicing

numbers = [10,20,30,40,50]

print(numbers[1:4])

Output

[20, 30, 40]

Modifying a List

fruits = [“Apple”,”Banana”,”Mango”]

fruits[1] = “Orange”

print(fruits)

output:

[‘Apple’, ‘Orange’, ‘Mango’]

List Methods

append()

Adds an item to the end.

Example

numbers = [1,2,3]

numbers.append(4)

print(numbers)

output:

[1,2,3,4]

insert()

Adds an item at a specific position.

numbers.insert(1,100)

print(numbers)

output:

[1,100,2,3,4]

extend()

Adds multiple elements.

numbers.extend([5,6])

print(numbers)

output:

[1,100,2,3,4,5,6]

remove()

Removes a specified value.

numbers.remove(100)

Get Burra Chandana’s stories in your inbox

Join Medium for free to get updates from this writer.

print(numbers)

output:

[1,2,3,4,5,6]

pop()

Removes an item by index.

numbers.pop(2)

print(numbers)

output:

[1,2,4,5,6]

clear()

Removes all items.

numbers.clear()

print(numbers)

output: []

sort()

Sorts the list.

marks = [45,12,90,32]

marks.sort()

print(marks)

output:

[12,32,45,90]

reverse()

Reverses the list.

marks.reverse()

print(marks)

output:

[90,45,32,12]

count()

Counts occurrences.

a = [1,2,2,3,2]

print(a.count(2))

output: 3

index()

Returns the first index of a value.

print(a.index(3))

output: 3

What is a Tuple?

A Tuple is an ordered collection enclosed in parentheses ( ).

Unlike lists, tuples cannot be modified after creation.

tuple_name = (item1, item2, item3)

Example:

colors = (“Red”,”Green”,”Blue”) print(colors)

output:

(‘Red’, ‘Green’, ‘Blue’)

Properties of Tuples

Ordered

Immutable

Allows duplicate values

Faster than lists

Supports indexing and slicing

Accessing Tuple Elements

colors = (“Red”,”Green”,”Blue”)

print(colors[0])

print(colors[-1])

output:

Red

Blue

Tuple Slicing

numbers = (10,20,30,40,50)

print(numbers[1:4])

Output:

(20,30,40)

Tuple Methods

Since tuples are immutable, they have only two built-in methods.

count()

numbers = (1,2,2,3,2)

print(numbers.count(2))

Output: 3

index()

print(numbers.index(3))

output: 3

Summary

List is a mutable collection enclosed in square brackets [ ].

Tuple is an immutable collection enclosed in parentheses ( ).

Both support indexing, slicing, and duplicate values.

Lists provide many methods for modifying data, while tuples offer only count() and index().

Use lists for data that changes and tuples for fixed, read-only data.

--

--