Skip to content
Related Articles

Related Articles

Improve Article

Differences and Applications of List, Tuple, Set and Dictionary in Python

  • Difficulty Level : Easy
  • Last Updated : 26 Jul, 2021

Lists: are just like dynamic sized arrays, declared in other languages (vector in C++ and ArrayList in Java). Lists need not be homogeneous always which makes it a most powerful tool in Python.

Tuple: A Tuple is a collection of Python objects separated by commas. In someways a tuple is similar to a list in terms of indexing, nested objects and repetition but a tuple is immutable unlike lists that are mutable.

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

Set: A Set is an unordered collection data type that is iterable, mutable and has no duplicate elements. Python’s set class represents the mathematical notion of a set.

Dictionary: in Python is an unordered collection of data values, used to store data values like a map, which unlike other Data Types that hold only single value as an element, Dictionary holds key:value pair. Key value is provided in the dictionary to make it more optimized.

List, Tuple, Set, and Dictionary are the data structures in python that are used to store and organize the data in an efficient manner.

List is a non-homogeneous data structure which stores the elements in single row and multiple rows and columnsTuple is also a non-homogeneous data structure which stores single row and multiple rows and columnsSet data structure is also non-homogeneous data structure but stores in single rowDictionary is also a non-homogeneous data structure which stores key value pairs
List can be represented by [ ]

Tuple can be represented by  

( )

Set can be represented by { }Dictionary  can be represented by { }
List allows duplicate elementsTuple allows duplicate elementsSet will not allow duplicate elementsSet will not allow duplicate elements but keys are not duplicated
List can use nested among allTuple can use nested among allSet can use nested among allDictionary can use nested among all
Example: [1, 2, 3, 4, 5]Example: (1, 2, 3, 4, 5)Example: {1, 2, 3, 4, 5}Example: {1, 2, 3, 4, 5}
List can be created using list() functionTuple can be created using tuple() function.Set can be created using set() functionDictionary can be created using dict() function.
List is mutable i.e we can make any changes in list.Tuple  is immutable i.e we can not make any changes in tupleSet is mutable i.e we can make any changes in set. But elements are not duplicated.Dictionary is mutable. But Keys are not duplicated.
List is orderedTuple is orderedSet is unorderedDictionary is ordered

Creating an empty list


Creating an empty Tuple


Creating a set



Creating an empty dictionary


Below is the program for implementation of List, tuple, set, and dictionary:


# Python3 program for explaining
# use of list, tuple, set and
# dictionary
# Lists
l = []
# Adding Element into list
print("Adding 5 and 10 in list", l)
# Popping Elements from list
print("Popped one element from list", l)
# Set
s = set()
# Adding element into set
print("Adding 5 and 10 in set", s)
# Removing element from set
print("Removing 5 from set", s)
# Tuple
t = tuple(l)
# Tuples are immutable
print("Tuple", t)
# Dictionary
d = {}
# Adding the key value pair
d[5] = "Five"
d[10] = "Ten"
print("Dictionary", d)
# Removing key-value pair
del d[10]
print("Dictionary", d)
Adding 5 and 10 in list [5, 10]
Popped one element from list [5]

Adding 5 and 10 in set {10, 5}
Removing 5 from set {10}

Tuple (5,)

Dictionary {5: 'Five', 10: 'Ten'}
Dictionary {5: 'Five'}

Applications of List, Set, Tuple, and Dictionary


  • Used in JSON format
  • Useful for Array operations
  • Used in Databases


  • Used to insert records in the database through SQL query at a time
    Ex: (1.’sravan’, 34).(2.’geek’, 35)
  • Used in parentheses checker


  • Finding unique elements
  • Join operations


  • Used to create a data frame with lists
  • Used in JSON

My Personal Notes arrow_drop_up
Recommended Articles
Page :