Frequently Asked Questions

What is the Difference Between a List and a Tuple?

List Tuple
List are mutable. Tuples are immutable.
Good for insertion and deletion of elements. Good for accessing elements.
Memory consumption is high. Memory consumption is low.
List is initialized with list(). Tuple is initialized with tuple().
List has many built-in functions. Tuples have comparatively fewer built-in functions.

Initialization


"""tuple initialization"""

a=()

b=tuple()

"""list initialization"""

c=[]

d=list()

Mutability


#create a list x

x=[1,"one",2]

#value updated at index 1

x[1]=3

print(x)

[1, 3, 2]
We are successfully able to update the value at index 1 from “one” to 3. Hence list are mutable.
#create a tuple y

y=(1,"one",2)

#update value at index 1

y[1]=3
If you try to update any value in a tuple, t throws a type error. Hence, tuples are immutable.

Other Popular Questions