• Teaching
    • Montessori Teacher Training 🔥
    • Yoga Teacher Training
  • Coding
    • Full Stack Development Course
    • Data Science Course
    • Python Programming Course
    • Software Testing Course
    • Architecting on AWS
  • Commerce
    • PwC Edge : Strategic Accounting and Finance Programme
    • ACCA Course
    • SAP Fico Course
    • Practical Accounting Course
    • SAP MM Course
    • HR Management Course in Kerala
  • Technical
    • Structural Design Course
    • Embedded Systems Software Engineering in Kerala
    • MEP Course
    • MEP QS Course
    • BIM Training Course
    • Quantity Survey Course
  • Finacademy
    • Forex Trading Course
    • Stock Market Course
    • Mutual Funds Course in Kerala
  • Digital Marketing
    • Digital Marketing Course
    • Performance Marketing Course
  • Language Learning
    • Spoken English Course
    • German Language Course
    • IELTS Exam Coaching
  • Exam Preparation
    • Kerala PSC Coaching
    • Kerala PSC LGS Coaching
    • KAS Coaching
    • Kerala PSC LDC Coaching
    • Kerala PSC LSGS Coaching
    • KPSC Industries Extension Officer Coaching
    • KPSC Technical Mechanical Coaching
    • KPSC Technical Electrical Coaching
    • Kerala PSC Technical Exam Preparation
    • KPSC Technical Civil Coaching
    • SBI PO Coaching
    • IBPS Clerk Coaching
    • IBPS PO Coaching
    • IBPS SO Coaching
    • Bank Exam Coaching
    • Lecturer in DIET Course
    • Kpsc HSA Coaching
    • KPSC LP UP Assistant Coaching
    • EMRS Coaching
    • KTET Coaching
    • SSC Coaching
    • SSC JE Coaching
    • SSC CGL Coaching
    • SSC CHSL Coaching
    • SSC MTS Coaching
    • UPSC Coaching
  • Health Care
    • DHA Course
    • OET Coaching
  • Other Exams
    • GATE Coaching
    • CAT Coaching
    • MAT Online Coaching
    • KMAT Online Coaching
Entri Blog
No Result
View All Result
Monday, May 19, 2025
  • Kerala PSC
    • Kerala PSC General
      • Kerala PSC Exams
      • KAS Exam
      • Kerala PSC VEO Notification
      • Kerala Police SI
      • Kerala PSC LDC Notification
      • Kerala PSC Village Field Assistant Notification
      • Kerala PSC LD Typist Notification
      • Kerala PSC Food Safety Officer
      • Kerala PSC Excise Inspector Notification
      • Kerala PSC BDO Notification
      • Kerala PSC CPO Notification
      • Kerala PSC LGS Notification
      • Fire and Rescue Officer
      • Women Fire and Rescue Officer
    • Kerala PSC Teaching
      • Kerala PSC HSA
      • Kerala PSC HSST
      • KTET
      • LP/UP Assistant
      • KVS
      • Railway Teacher
    • Kerala PSC Technical
      • LSGD AE
      • Draftsman/Overseer
      • IEO
      • ATP
      • Polytechnic Lecturer
      • AE Electronics
      • Assistant Engineer
  • Banking
    • IBPS PO Notification
    • IBPS Clerk Notification
    • SBI PO Notification
    • SBI Clerk Notification
    • SBI SO Notification
    • SBI Apprentice Notification
    • Canara Bank PO Notification
    • Indian Bank PO Notification
    • RBI Assistant Notification
    • RBI Office Attendant Notification
    • IBPS RRB Notification
    • IBPS RRB Office Assistant Notification
  • Skilling
    • Coding
    • Spoken English
    • Stock Market
      • Share Market Today News
      • Share Market Analysis
    • Digital Marketing
    • Accounting Course
    • SAP
    • OET
    • German
    • IELTS
    • Quantity Survey
    • MEP
    • Structural Design
    • Montessori
    • Yoga Teaching
    • Oil and Gas
  • Courses
    • Data Science Course
      • Data Science Malayalam
      • Data Science Course in Tamil
      • Data Science Course in Telugu
      • Data Science Training in Kochi
      • Data Science Training in Trivandrum
      • Data Science Course in Calicut
      • Data Science Training in Thrissur
    • Data Analytics Course
      • Data Analytics Course in Malayalam
      • Data Analytics Course in Tamil
      • Data Analytics Course in Telugu
    • Technical Upskilling
      • Quantity Surveying Course
      • Structural Design Course
      • BIM Course in Kerala
      • MEP Course
      • Embedded System Course
      • MEP Quantity Surveying Course
      • MEP Course in Kochi
      • Quantity Surveyor Course in Tamil
      • Quantity Surveying Course in Telugu
      • Quantity Surveyor Course in Hyderabad
      • Quantity Surveying Course in Chennai
      • MEP Design Course in Kerala
      • HVAC Course
      • Steel Structure Design Course
      • RCC Design Course
    • Full Stack Developer Course
      • Full Stack Development Malayalam
      • Full Stack Development Hindi
      • Full Stack Development Tamil
      • Full Stack Development Telugu
      • Full Stack Development Kannada
    • Stock Market Course
      • Stock Market Course in Malayalam
      • Stock Market Course in Tamil
      • Stock Market Course in Kannada
      • Options Trading Course
    • Mutual Funds Course
    • Forex Trading Course
    • Spoken English Course
      • Spoken English Course in Malayalam
      • Spoken English Course in Hindi
      • Spoken English Course in Telugu
      • Spoken English Course in Tamil
      • Spoken English Course in Kannada
    • Python Programming Course
    • Software Testing Course
      • Software Testing Course in Malayalam
      • Software Testing Course in Tamil
      • Software Testing Course in Telugu
    • AWS Solutions Architect Associate Course
    • PwC Edge : Strategic Accounting and Finance Programme
    • Practical Accounting Course
      • Accounting Course in Malayalam
      • Accounting Course in Tamil
      • Tally Course
      • Taxation Course
      • UAE Accounting
      • GST Course
      • Zoho Books Training
      • GST Practitioner Course in Kerala
      • GCC VAT Course
    • ACCA Training Online
      • ACCA Course in Kerala
    • SAP Training Courses
      • SAP FICO Course
      • SAP MM Course
      • SAP SD Training
      • SAP FICO Course in Tamil
      • SAP MM Course in Tamil
    • HR Management Course
    • Performance Marketing Course
    • Mern Stack Developer Course
      • Full Stack Developer Course in Kochi
      • Full Stack Developer Course in Trivandrum
      • Full Stack Developer Course in Calicut
      • Full Stack Developer Course in Pune
      • Full Stack Developer Course in Bangalore
      • Full Stack Developer Course in Hyderabad
      • Full Stack Developer Course in Chennai
      • Full Stack Developer Course in Indore
      • Full Stack Developer Course in Jaipur
      • Full Stack Developer Course in Coimbatore
    • Digital Marketing Training
      • Digital Marketing Course in Kochi
      • Digital Marketing Course in Trivandrum
      • Digital Marketing Course in Calicut
      • Digital Marketing Course in Kollam
      • Digital Marketing Course in Thrissur
      • Digital Marketing Course in Kottayam
      • Digital Marketing Course in Kannur
    • Montessori Teacher Training
      • Montessori Teacher Training in Calicut
      • Montessori Teacher Training in Kochi, Ernakulam
      • Montessori Teacher Training in Trivandrum
      • Montessori Teacher Training in Kollam
      • Montessori Teacher Training in Malayalam
      • Montessori Teacher Training in Kannada
    • Other Courses
      • German Language Course
      • OET Coaching
        • OET for Pharmacist
        • OET for Nurses
      • DHA Course
      • MOH Exam Coaching
      • Nurses Recruitment Abroad
      • FMGE Coaching
      • ChatGPT Course
      • Forex Trading Course
      • Yoga Teacher Training Course
      • Diploma in Early Childhood Care and Education
      • Business Administration & Hospital Management Course
      • Hospital and Healthcare Administration
      • AI for Teachers Course
  • Others
    • Railway
      • RRB Technician Notification
      • RRB JE Notification
      • RRB ALP Notification
      • RRB NTPC Notification
      • RRB RPF Notification
      • RRB RPF SI Notification
      • RRB RPF Constable Notification
      • RRB Group D Notification
      • RRB RPSF SI Notification
      • RRB SSE Notification
    • SSC
      • SSC CPO Notification
      • SSC MTS Notification
      • SSC CGL Notification
      • SSC CHSL Notification
      • SSC GD Constable Notification
      • SSC Stenographer Notification
      • SSC JE Notification
      • SSC CAPF Notification
      • SSC JHT Notification
      • Delhi Police Constable Notification
      • Delhi Police SI Notification
    • GATE
    • MAT
    • KMAT
      • KMAT Kerala 2024
    • TET
      • APTET
      • CTET
      • DSSSB
      • Karnataka TET
      • Kerala TET
        • KTET Notification
      • KVS
      • MPTET
      • SUPER TET
      • TNTET
      • TSTET
      • UPTET
    • UPSC
      • UPSC CAPF Notification
      • UPSC CDS Notification
      • UPSC NDA Notification
      • UPSC Civil service Notification
  • Free Learn
    • Free Courses
      • Free Coding Courses
        • C Langauge Courses
        • Free Data Science Courses
        • Free Full Stack Developer Courses
        • Free Python Programming Courses
      • Free Accounting Courses
      • Free Digital Marketing Courses
        • Free SEO Courses
        • Web Development for Marketers
      • Engineering Upskilling Courses
      • Free Hospital Administration Courses
      • Free OET Training
      • Free SAP Courses
      • Free Teachers Training Courses
      • Free Trading Courses
        • Free Stock Market Courses in Malayalam
        • Free Options Trading Course Malayalam
        • Free Forex Trading Courses Malayalam
        • Free Personal Finance Courses Malayalam
    • Question Answer
    • Aptitude Questions
    • Webinars
  • Test Prep
    • Kerala PSC Coaching
      • KPSC Degree Level Exam Preparation
      • Kerala PSC 12th Level Exam Preparation
      • Kerala PSC 10th Level Exam Preparation
      • KAS Coaching
      • Kerala PSC LDC Coaching
      • Kerala PSC LD Typist Coaching
      • Kerala PSC Fireman Coaching
      • KSFE Assistant Exam Preparation
      • Secretariat Office Attendant Coaching
      • Secretariat Assistant Coaching
      • Kerala PSC SI Exam Coaching
      • Khadi Board LDC Exam Preparation
      • Devaswom Board LDC Coaching
      • University LGS Exam Preparation
      • University Assistant Exam Coaching
      • KPSC Scientific Officer Exam Coaching
      • KPSC Probation Officer Grade II
      • KPSC Food Safety Officer Coaching
      • KWA Sanitary Chemist Coaching
      • KPSC Diary Farm Instructor Exam Coaching
      • Kerala PSC KWA Lab Assistant Exam Coaching
      • Kerala PSC ICDS Supervisor Exam Coaching
      • KPSC Finger Print Searcher Coaching
      • Kerala PSC Welfare Officer Gr. II Exam Coaching
      • KPSC Assistant Dental Surgeon Coaching
    • KPSC Teaching Exams
      • HSA Exam Preparation
      • KPSC HSA Social Science Coaching
      • KPSC HSA Physical Science Coaching
      • KPSC HSA English Coaching
      • KPSC Junior Language Teacher Hindi
      • KTET Coaching
      • SET Coaching
      • LP/UP Assistant Exam Coaching
      • HSST Exam Preparation
      • HSST Commerce Exam Coaching
      • Kerala PSC Lecturer in Diet Coaching
      • KVS PGT/TGT Coaching
    • Kerala PSC Technical Exams Coaching
      • Assistant Engineer Electrical Exam Coaching
      • Assistant Engineer Electronics Coaching
      • Assistant Engineer Mechanical Coaching
      • Kerala PSC Industries Extension Officer Coaching
      • KPSC LSGD AE Exam Coaching
      • KPSC Civil Engineering Exam Coaching
      • KPSC Mechanical Engineering Exam Coaching
      • KPSC Electrical Engineering Exam Coaching
      • KPSC Electronics Engineering Exam Coaching
      • KPSC Technical Computer Science Coaching
      • KPSC Tradesman Turning Coaching
      • Kerala PSC Overseer Exam Coaching
      • KPSC Assistant Town Planner Coaching
      • Lecturer in Polytechnic Electronics Coaching
    • Teaching Exams Coaching
      • CSIR NET Exam Coaching
      • EMRS Coaching
      • CTET Exam Online Coaching
    • IELTS Training Online
    • Bank Exam Coaching Online
      • SEBI Grade A Coaching
      • IBPS SO Online Coaching
      • IBPSC PO Online Coaching
      • IBPSC Clerk Online Coaching
      • SBI PO Coaching
      • SBI Clerk Online Coaching
      • SBI Apprentice Class
      • SBI SO Online Coaching
      • RBI Grade B Coaching
      • RBI Assistant Coaching
      • CSEB Exam Coaching
      • IBPS RRB Coaching
      • IBPS RRB PO Coaching
      • Canara Bank Po Exam Coaching
      • Kerala Gramin Bank Coaching
      • Kerala Bank Exam Coaching
        • Kerala Bank Clerk Exam Coaching
        • Kerala Bank Office Attendant Exam Coaching
        • Kerala Bank Assistant Manager Exam Coaching
      • JCI Exam Coaching
      • NABARD Grade A Coaching
      • LIC AAO Coaching Online
    • UPSC Online Coaching
      • UPSC CAPF Online Coaching
    • SSC Online Coaching
      • SSC JE Online Coaching
      • SSC CGL Coaching
      • SSC CGL AAO Coaching
      • SSC CGL CBI Inspector Coaching
      • SSC CHSL Coaching
      • SSC MTS Coaching
      • SSC Stenographer Coaching
      • SSC GD Online Coaching
    • RRB Exams Coaching
      • RRB RPF Exam Coaching
      • RRB NTPC Exam Coaching
      • RRB JE Online Coaching
      • RRB JE Electronics Coaching
      • RRB ALP Exam Coaching
      • RRB Technician Exam Coaching
    • CAT Online Coaching
    • CMAT Online Coaching
    • XAT Exam Coaching
    • GATE Online Coaching
      • GATE CE Online Coaching
      • GATE ME Online Coaching
      • GATE EE Online Coaching
    • NMAT Exam Coaching
    • AAI ATC Jr Executive Coaching
    • Cochin Shipyard Executive Trainee Coaching
    • BEL Probationary Engineer Coaching
    • HPCL Junior Executive Coaching
Free Courses
Entri Blog
  • HTML Tutorial
  • DSA Tutorials
  • Tutorials in Hindi
    • HTML Tutorial for Beginners in Hindi
    • Python Tutorial for Beginners in Hindi
    • GIT and GITHUB Tutorial for Beginners in Hindi
  • Tutorials in Tamil
    • JavaScript Tutorial in Tamil
  • Tutorials in Telugu
    • HTML Tutorial For Beginners in Telugu
    • CSS Tutorial for Beginners in Telugu
    • Bootstrap Tutorial for Beginner in Telugu
  • Tutorials in Kannada
    • HTML Tutorial For Beginners in Kannada
entri exclusive offers entri exclusive offers
Home Articles

Difference Between List and Tuple in Python

by Aleena V Noushad
December 29, 2023
in Articles, Python Programming
Difference Between List and Tuple in Python
Share on FacebookShare on WhatsAppShare on Telegram

Table of Contents

  • What is a List?
  • What is a Tuple?
  • Examples
  • Key Differences Between List and Tuple in Python
  • Key Similarities Between List and Tuple in Python
  • Frequently Asked Questions

A versatile and powerful language, Python provides various element types such as list and tuple. Each of these elements has its own unique properties and functions. Let’s dive deeper into understanding each of these elements.

Lists and tuples are the two basic classes of data structures in Python. Although they may seem similar, they have unique characteristics that set them apart.

Distinguishing Between List, Tuple in Python

Let’s delve into the differences between List, Tuple, Set, and Dictionary in Python:

Parameters List Tuple
Basics A list is similar to an array in other languages (like ArrayList in Java or vector in C++). Tuples are collections of Python objects separated by commas.
Homogeneity A list is a non-homogeneous data structure that stores elements in columns and rows. A tuple is a non-homogeneous data structure that stores elements in columns and rows.
Representation A List is represented by [ ] A Tuple is represented by ( )
Duplicate elements It permits duplicate elements. It permits duplicate elements.
Nested Among All It can be nested in a List. It can be nested in a Tuple.
Example [1, 2, 3, 4, 5] (10, 20, 30, 40, 50)
Function for Creation A list can be created using the list() function. A tuple can be created using the tuple() function.
Mutation It is mutable, allowing modifications. It is immutable, not allowing modifications.
Order It maintains order. It maintains order.
Empty Elements An empty list can be created using:

l=[]

An empty tuple can be created using:

t=()

What is a List?

In other programming languages, list objects are declared similarly to arrays. Lists need not always be homogeneous, so they can simultaneously store items of different data types. Lists thus become the most useful tool. A list is a type of Python container data structure used to store many pieces of data at once. Lists are useful when we need to iterate over some elements and keep items.

The list has the following features –

  • You can use Python lists to store data of multiple types simultaneously.
  • Lists help preserve data sequences and further process those sequences in other ways.
  • Lists are dynamic.
  • Lists are mutable.
  • Lists are ordered.
  • An index is used to traverse a list.

List Syntax

A list is initiated with the [ ] symbol.

Here’s an example of declaring a list in python.

num_list = [1,2,3,4,5]

print(num_list)

alphabets_list = [‘a’,‘b’,‘c’,‘d’,‘e’]

print(alphabets_list)

A list can contain data of different data types. You can initiate it as follows – mixed_list = [‘a’, 1,‘b’,2,‘c’,3,‘4’]

print(mixed_list)

You can create nested lists as well. A nested list is a list inside a list.

nested_list = [1,2,3,[4,5,6],7,8]

print(nested_list

What is a Tuple?

1: Which of the following data types is immutable in Python?

2: What does the len() function do in Python?

3: Which keyword is used to define a function in Python?

4: What will print(type([1, 2, 3])) output?

5: Which statement is correct about Python indentation?

    Fill out the form to see the results

    Ever wondered how much you really know? It's time to put your brain to the test!

    A tuple is another data structure for storing a collection of items of many data types, but unlike mutable lists, tuples are immutable. In other words, a tuple is a collection of items separated by commas. Because of its static structure, a tuple is more efficient than a list.

    A python tuple has the following features –

    • Tuples are used to store heterogeneous and homogeneous data.
    • Tuples are immutable in nature.
    • Tuples are ordered
    • An index is used to traverse a tuple.
    • Tuples are similar to lists. It also preserves the data sequence.

    Tuple Syntax

    A tuple is initiated with the () symbol.

    Here’s an example of declaring a tuple in python.

    num_tuple = (1,2,3,4,5)

    print(num_tuple)

    alphabets_tuple = (‘a’,‘b’,‘c’,‘d’,‘e’)

    print(alphabets_tuple)

    A list can contain data of different data types. You can initiate it as follows –

    mixed_tuple = (‘a’, 1,‘b,’ 2,‘c,’ 3, ‘4’).

    print(mixed_tuple)

    You can create nested lists as well. A nested list is a list inside a list.

    nested_tuple = (1,2,3,(4,5,6),7,8)

    print(nested_tuple)

    Syntax Differences

    List and tuple act as containers for storing objects. But there is a difference in its use cases and syntax as well.

    Lists are surrounded by square brackets [ ] while tuples are surrounded by round brackets ( ).

    Creating a list and tuple in python.

    list_numbers  = [1,2,3,4,5]

    tuple_numbers  = (1,2,3,4,5)

    print(list_numbers)

    print(tuple_numbers)

    We can use the type function to check the data type of any object.

    type(list_numbers)

    type(tuple_numbers)

    “Get hands-on with our python course – sign up for a free demo!”

    Difference Between List and Tuple in Python (An In-Depth Explanation)

    The primary difference between tuples and lists is that tuples are immutable, unlike lists, which are mutable. Therefore, it is possible to change a list, but not a tuple.

    The contents of a tuple cannot change once it has been created in Python due to the immutability of tuples.

    There is no way to keep changing tuples. Error message if you attempt to change one of the items:

    names = (“Raj”,”John”,”Jabby”,”Raja”)

    names[2] = “Kelly”

    Traceback (most recent call last):

    File “<stdin>”, line 4, in <module>

    TypeError: ‘tuple’ object does not support item assignment

    If you’re familiar with lists and maps, you know that they can be edited. You can add or remove items or reassign them to different variables. But tuples? Well, you can’t do any of that.

    The reason is simple: tuples are immutable, which means that once you create them, you can’t change their contents. The length of the tuples is also fixed. They remain the same length throughout the program’s life cycle.

    So why would we use immutable data structures like tuples anyway? One reason is that they have little overhead compared to mutable data structures like lists and maps.

    Mutable List vs. Immutable Tuples

    We have already heard that tuples are immutable while lists are mutable. It simply means that you can change the existing values ​​in the list. But you cannot change the same value if it is stored in a tuple.

    Let’s take an example to understand the immutability of tuples

    Create a new list list_num and initialize it with 5 values.

    list_num=[1,2,3,4,5]

    Let’s replace 3 with 5.

    list_num[2] = 5

    print(list_num)

    [1,2,5,4,5]

    Carrying out similar operation in tuple.

    Create a new tuple tuple_num and initialize it with five values.

    tuple_num=(1,2,3,4,5)

    Let’s replace 3 with 5.

    tup_num[2] = 7

    It will the following error –

    [1,2,7,4,5]

    Traceback (most recent call last):

    File “python”, line 3, in <module>

    TypeError: ‘tuple’ object does not support item assignment.

    The error makes it clear that item assignment is not supported in the tuple. Hence it is immutable.

    Available Operations

    Because a list is mutable, it has many built-in operations that you can use to achieve different results. Let’s look at such list operations.

    append()

    Used to add elements to the list. Elements are added to the end of the list. You can only add one element at a time. Using a loop allows you to add multiple elements at once.

    numList = [1,2,3]

    numList.append(4)

    numList.append(5)

    numList.append(6)

    Using a loop for insertion

    for i in range(7, 9):

    numList.append(i)

    print(numList)

    extend()

    The extension operation is used to add elements to the end of a list, like the join operation. But extend() allows you to add multiple elements at once.

    numList = [1,2,3]

    numList.extend([4, 5, 6])

    print(numList)

    insert()

    Allows you to add a new element to the list at a given position. Unlike append, it does not add elements to the end. It takes two arguments, the first argument is the position and the second argument is the element. You can insert one element at a time. So you can use a loop to insert multiple elements.

    numList = [1,2,3]

    numList.insert(3, 4)

    numList.insert(4, 5)

    numList.insert(5, 6)

    print(numList)

    remove()

    Used to remove an element from a list. If there are multiple elements, only the first occurrence of the element is removed.

    stringList = [‘List’, ‘makes learning fun!’, ‘for us!’]

    stringList.remove(‘makes learning fun!’)

    print(stringList)

    pop()

    Used to remove elements from any position in the list. Pop() takes one argument, the position of the element.

    numList = [1,2,3,4,5]

    numList.pop(4)

    print(numList)

    slice.

    Used to print a subset of a list. You must specify a start and end position for the slicing operation.

    numList = [1,2,3,4,5,6,7,8,9]

    print(numList[:9])  # prints from beginning to end index

    print(numList[2:])  # prints from start index to end of list

    print(numList[2:9]) # prints from start index to end index

    print(numList[:])   # prints from beginning to end of list

    reverse()

    Reverse operation reverses the original list. If you want to reverse without affecting the original list, you should use the slice function with a negative index.

    numList = [1,2,3,4,5,6,7,8,9]

    print(numList[::-1])  # does not modify the original list

    numList.reverse()     # modifies the original list

    print(numList)

    len()

    It returns the length of the list

    numList = [1,2,3,4,5,6,7,8,9]

    print(len(numList))

    min()

    It returns the minimum value in the list. You can use min operation successfully only if the list is homogenous.

    print(min([1, 2, 3]))

    max()

    It returns the maximum value in the list. You can use min operation successfully only if the list is homogenous.

    print(max([1, 2, 3]))

    count()

    Count operation returns the count of specified element in the list. It takes the element as an argument.

    numList = [1,2,2,4,4,6,8,8,9]

    print(numList.count(3))

    concate()

    It is used to merge two lists into a new list. + sign is used to combine two lists.

    numList = [4,5]

    stringList = [‘Python’, ‘is fun!’]

    print(numList+stringList )

    multiply()

    Python also allows multiplying the list n times. The resultant list is the original list iterated n times.

    numList = [1,2,3,4,5,6,7,8,9]

    print(numList*2)

    index()

    It is used to find an element based on the index position. You need to pass two arguments to it, the first is the starting position, and the second is the ending position. When supplied, the element is searched only in the sub-list bound by the begin and end indices. When not supplied, the element is searched in the whole list.

    print(stringList.index(‘HelloWorld’))            # searches in the whole list

    print(stringList.index(‘HelloWorld’, 0, 2))     # searches from 0th to 2nd position

    sort()

    It is used to sort the list in ascending order. You can perform this operation only on a homogeneous list. Using sort() on a heterogeneous list will throw an error.

    numList = [4, 2, 6, 5, 0, 1]

    numList.sort()

    print(numList)

    clear()

    It clears all the elements from the list and empties it.

    numList = [1,2,3,4,5,6,7,8,9]

    numList.clear()

    print(numList)

    Immutability reduces the number of inbuilt functions a tuple has. Let’s take a look at such tuple operations.

    min()

    It returns the minimum value in the tuple. You can use the min operation successfully only if the tuple is homogenous.

    print(min((1, 2, 3)))

    max()

    It returns the maximum value in the tuple. You can use min operation successfully only if the tuple is homogenous.

    print(max((1, 2, 3)))

    slice.

    It is used to print a subset of the tuple. You have to specify starting position and ending position for the slicing operation.

    myTuple = [1,2,3,4,5,6,7,8,9]

    print(myTuple[:9])  # prints from beginning to end index

    print(myTuple[2:])  # prints from start index to end of tuple

    print(myTuple[2:9]) # prints from start index to end index

    print(myTuple[:])   # prints from beginning to end of tuple

    len()

    It returns the length of the tuple

    myTuple = [1,2,3,4,5,6,7,8,9]

    print(len(myTuple))

    del()

    Tuples are immutable, but we can remove the tuple elements using del operation.

    Tuple1 = (1, 3, 4, ‘test’, ‘red’)

    del (Tuple1[1])

    Membership In Tuple

    If you want to check whether an element belongs to the tuple or not, you can use a keyword to check its membership.

    Tuple1 = (1, 3, 4, ‘test’, ‘red’)

    print (1 in Tuple1)

    print (5 in Tuple1)

    Size Comparison

    There is a difference in lengths between these two data structures. The length of a tuple is fixed, while the length of a list is variable. Therefore, lists can have different sizes, but tuples cannot.

    Tuples are allocated large blocks of memory with lower overhead than lists because they are immutable; while small blocks of memory are allocated for lists. Thus, tuples tend to be faster than lists if there are a large number of elements.

    a= (1,2,3,4,5,6,7,8,9,0)

    b= [1,2,3,4,5,6,7,8,9,0]

    print(‘a=’,a.__sizeof__())

    print(‘b=’,b.__sizeof__())

    a=104

    b=120

    Different Use Cases

    Python’s lists are best suited to store data in the following situations:

    1. Several types of data can be stored in lists, and their index can be used to access them.
    2. Lists are good for mathematical operations on a group of elements because Python allows you to perform these operations directly on the list.
    3. If you don’t know how many elements will be stored in your list ahead of time, it’s easy to increase or decrease its size as needed.

    Python’s tuples are best suited to store data in the following situations:

    1. It’s best to use a tuple when you know the exact information that will go into the object’s fields.
    2. For example, if you want to store credentials for your website, it’s okay to use a tuple.
    3. The tuples are immutable (unchangeable), so they can only be used as keys for dictionaries. But if you want to use a list as a key, make it into a tuple first.

    “Learn Python Programming course – enroll now!”

    🚀 Start Coding Today! Enroll Now with Easy EMI Options. 💳✨

    Gain expertise in Django and open doors to lucrative opportunities in web development.

    Start Learning With EMI Payment Options

    Examples

    Tuples as Dictionary

    As tuples are hashable, you can use them as keys for dictionaries.

    tuplekey = {}

    tuplekey[(‘blue’, ‘sky’)] = ‘Good’

    tuplekey[(‘red’,’blood’)] = ‘Bad’

    print(tuplekey)

    Tuple Packing and Unpacking

    Packing and unpacking improves the code readability.

    Packing means assigning multiple values to the tuple.

    Unpacking means assigning values to individual variables.

    Tuple Packing

    person = (“Rohan”, ‘6 ft’, “Employee”)

    print(person)

    Tuple Unpacking

    person = (“Rohan”, ‘6 ft’, “Employee”)

    (name, height, profession) = person

    print(name)

    print(height)

    print(profession)

    When to Use Tuples Over Lists?

    Tuples are immutable. Therefore, they are primarily used to store data that does not change often. Any operation can store data in a tuple when you don’t want it to change.

    Tuples are great to use if you want the data in your collection to be read-only, never change, and always stay the same and constant.

    With this capability and the guarantee that the data never changes, you can use tuples in dictionaries and sets that require the elements in them to be of immutable type.

    This is useful when you need to store values ​​that do not change over time, such as a person’s date of birth or height.

    Key Differences Between List and Tuple in Python

    • Lists are mutable, while tuples are immutable.
      • i.e., the elements of the list can be changed, after the creation, while the elements of the tuples can’t be modified.
    • The size of the tuples is fixed, while the list can have a variable size.
      • i.e., elements can be added or removed from the list but can’t be done in the tuple.
    • Since tuples are immutable, they are generally faster than the list.
    • Lists are used for data that needs to be changed frequently, while tuples are used for data that doesn’t need to be changed frequently.

    Key Similarities Between List and Tuple in Python

    • They both hold collections of items and are heterogeneous data types, meaning they can contain multiple data types simultaneously.
    • They’re both ordered, which implies the items or objects are maintained in the same order as they were placed until changed manually.
    • Because they’re both sequential data structures, we can iterate through the objects they hold; hence, they are iterables.
    • An integer index, enclosed in square brackets [index], can be used to access objects of both data types.

    Related Articles

    How To Learn Python At Home? Why Python Is Used For Data Science?
    Python Full Stack vs Java Full Stack Developer Object Oriented Programming Python
    Best Online Python Course with Certificate A Step-by-Step Guide for Getting a Job as a Python Developer

    🚀 Start Coding Today! Enroll Now with Easy EMI Options. 💳✨

    Gain expertise in Django and open doors to lucrative opportunities in web development.

    Start Learning With EMI Payment Options

    Frequently Asked Questions

    What is a List in Python?

    A list in Python is like a dynamically sized array that gets declared in other languages (Arraylist in the case of Java, vector in the case of C++). The lists don’t always need to be homogeneous in nature.

    What is a Tuple in Python?

    A Tuple in Python refers to the collections of various objects of Python separated by commas between them. Tuples are similar to the lists in terms of repetition, nested objects, and indexing. The difference is that a tuple, unlike a list, is immutable.

    What is the main difference between List and Tuple in Python?

    The main difference between a list and a tuple in Python lies in their nature. A list is mutable and dynamic, whereas a tuple is immutable and static. Lists consume more memory and are slower compared to tuples. Lists also have more built-in methods and are more prone to errors.
    Our Other Courses
    MEP Course Quantity Surveying Course Montessori Teachers Training Course
    Performance Marketing Course  Practical Accounting Course Yoga Teachers Training Course
    ×





      Share62SendShare

      Aleena V Noushad

      Aleena is a passionate Blog writer and a Postgraduate in Master of Computer Application. She also holds a diploma in Aviation and Hospitality. She has been writing for Entri over the past three years, specialising in exam preparation and skill and career development

      Related Posts

      IOB Local Bank Officer Recruitment 2025 Notification Out
      Articles

      IOB Local Bank Officer Recruitment 2025 Notification Out

      May 19, 2025
      Top 30 Preschool Teacher Interview Questions And Answers
      Articles

      Top 30 Preschool Teacher Interview Questions And Answers

      May 19, 2025
      How To Become A Preschool Teacher: A Complete Guide
      Articles

      How To Become A Preschool Teacher: A Complete Guide

      May 19, 2025
      Next Post
      Tips to Develop a Reading Habit for the OET Test An Expert's Guide

      Tips to Develop a Reading Habit for the OET Test: An Expert's Guide

      More to Explore

      1. Future of Python Developers
      2. Python Online Course with 100% Placement
      3. Steps To Code A Video Conferencing App Using Python
      4. Python Advanced Interview Questions and Answers
      5. Introduction to Data Visualization in Python
      6. Python developer – Skills, Courses, Job Roles
      7. Python Developer Salary in India
      8. Method Overloading in Python

      Practice Programs

      1. Program for Finding Factorial of a Number in Python
      2. Python Program to Convert Decimal to Binary Number
      3. Python Program for Fibonacci Series
      4. Prime Number Program in Python
      5. Python Program to Check Armstrong Number

      Python Training in Different Cities

      1. Python Training in Kochi
      2. Python Training in Trivandrum
      3. Python Training in Calicut

      Free Tutorials For You

      1. SQL Tutorial for Beginners PDF
      2. Python Tutorial for Beginners in Hindi
      3. GIT and GITHUB Tutorial for Beginners in Hindi
      4. HTML Exercises to Practice
      5. JavaScript Tutorial in Tamil
      6. DSA Practice Series
      7. Microsoft Excel Malayalam Tutorial
      8. Learn Bootstrap in Tamil
      9. Introduction to CSS in Malayalam
      10. Introduction to JavaScript in Malayalam
      11. Java Programming Notes PDF
      12. Introduction to HTML in Malayalam

      Courses

      • Data Science Course
      • Full Stack Developer Course
      • Software Testing Course
      • Data Science Course in Malayalam
      • Full Stack Developer Course in Malayalam
      • Full Stack Developer Course in Hindi
      • Full Stack Developer Course in Tamil
      • Full Stack Developer Course in Telugu
      • Full Stack Developer Course in Kannada
      • Python Programming Course
      • Practical Accounting Course
      • Structural Design Course
      • Quantity Surveying Course
      • Embedded Systems Course in Kerala
      • BIM Course
      • MEP Course
      • MEP QS Course
      • Stock Market Course
      • Stock Market Course in Malayalam
      • Stock Market Course in Tamil
      • Stock Market Course in Kannada
      • Forex Trading Course
      • Mutual Funds Course
      • PwC Edge : Strategic Accounting and Finance Programme
      • SAP FICO Training
      • SAP MM Training
      • SAP SD Training
      • ACCA Online Course
      • HR Management Course

      Company

      • Become a teacher
      • Login to Entri Web

      Spoken English Courses

      • Spoken English Course
      • Spoken English Course in Malayalam
      • Spoken English Course in Hindi
      • Spoken English Course in Tamil
      • Spoken English Course in Telugu
      • Spoken English Course in Kannada
      • Spoken English Course for Housewives
      • Spoken English Course for Working Professionals
      • Spoken English Course for School Students
      • Spoken English Course for College Students
      • Spoken English Course for Job Seekers
      • AI Powered Spoken English Course

      Quick Links

      • Explore Free Courses
      • Aptitude Questions
      • Articles
      • Videos
      • Entri Daily Quiz Practice
      • Current Affairs & GK
      • News Capsule – eBook
      • Preparation Tips
      • Kerala PSC Gold
      • Entri Skilling
      • Kerala PSC

      Other Courses

      • OET Coaching Classes
      • DHA Course
      • Nurse Recruitment Abroad
      • Montessori Teachers Training
      • Performance Marketing Course
      • German Language Course
      • Yoga Teacher Training Course
      • Digital Marketing Course
      • Options Trading Course
      • German Language A1 Course
      • German Language A2 Course
      • German Language B1 Course
      • German Language B2 Course
      • Diploma in Early Childhood Care and Education
      • Hospital and Healthcare Administration
      • Business Administration & Hospital Management
      • Hospital and Healthcare Administration

      Popular Exam

      • IBPS Exam
      • SBI Exam
      • Railway RRB Exam
      • Kerala PSC
      • Tamil Nadu PSC
      • Telangana PSC
      • Andhra Pradesh PSC
      • MPPSC
      • UPPSC
      • Karnataka PSC
      • Staff Selection Commission Exam
      • GATE

      © 2023 Entri.app - Privacy Policy | Terms of Service

      No Result
      View All Result
      • Kerala PSC
        • Kerala PSC General
          • Kerala PSC Exams
          • KAS Exam
          • Kerala PSC VEO Notification
          • Kerala Police SI
          • Kerala PSC LDC Notification
          • Kerala PSC Village Field Assistant Notification
          • Kerala PSC LD Typist Notification
          • Kerala PSC Food Safety Officer
          • Kerala PSC Excise Inspector Notification
          • Kerala PSC BDO Notification
          • Kerala PSC CPO Notification
          • Kerala PSC LGS Notification
          • Fire and Rescue Officer
          • Women Fire and Rescue Officer
        • Kerala PSC Teaching
          • Kerala PSC HSA
          • Kerala PSC HSST
          • KTET
          • LP/UP Assistant
          • KVS
          • Railway Teacher
        • Kerala PSC Technical
          • LSGD AE
          • Draftsman/Overseer
          • IEO
          • ATP
          • Polytechnic Lecturer
          • AE Electronics
          • Assistant Engineer
      • Banking
        • IBPS PO Notification
        • IBPS Clerk Notification
        • SBI PO Notification
        • SBI Clerk Notification
        • SBI SO Notification
        • SBI Apprentice Notification
        • Canara Bank PO Notification
        • Indian Bank PO Notification
        • RBI Assistant Notification
        • RBI Office Attendant Notification
        • IBPS RRB Notification
        • IBPS RRB Office Assistant Notification
      • Skilling
        • Coding
        • Spoken English
        • Stock Market
          • Share Market Today News
          • Share Market Analysis
        • Digital Marketing
        • Accounting Course
        • SAP
        • OET
        • German
        • IELTS
        • Quantity Survey
        • MEP
        • Structural Design
        • Montessori
        • Yoga Teaching
        • Oil and Gas
      • Courses
        • Data Science Course
          • Data Science Malayalam
          • Data Science Course in Tamil
          • Data Science Course in Telugu
          • Data Science Training in Kochi
          • Data Science Training in Trivandrum
          • Data Science Course in Calicut
          • Data Science Training in Thrissur
        • Data Analytics Course
          • Data Analytics Course in Malayalam
          • Data Analytics Course in Tamil
          • Data Analytics Course in Telugu
        • Technical Upskilling
          • Quantity Surveying Course
          • Structural Design Course
          • BIM Course in Kerala
          • MEP Course
          • Embedded System Course
          • MEP Quantity Surveying Course
          • MEP Course in Kochi
          • Quantity Surveyor Course in Tamil
          • Quantity Surveying Course in Telugu
          • Quantity Surveyor Course in Hyderabad
          • Quantity Surveying Course in Chennai
          • MEP Design Course in Kerala
          • HVAC Course
          • Steel Structure Design Course
          • RCC Design Course
        • Full Stack Developer Course
          • Full Stack Development Malayalam
          • Full Stack Development Hindi
          • Full Stack Development Tamil
          • Full Stack Development Telugu
          • Full Stack Development Kannada
        • Stock Market Course
          • Stock Market Course in Malayalam
          • Stock Market Course in Tamil
          • Stock Market Course in Kannada
          • Options Trading Course
        • Mutual Funds Course
        • Forex Trading Course
        • Spoken English Course
          • Spoken English Course in Malayalam
          • Spoken English Course in Hindi
          • Spoken English Course in Telugu
          • Spoken English Course in Tamil
          • Spoken English Course in Kannada
        • Python Programming Course
        • Software Testing Course
          • Software Testing Course in Malayalam
          • Software Testing Course in Tamil
          • Software Testing Course in Telugu
        • AWS Solutions Architect Associate Course
        • PwC Edge : Strategic Accounting and Finance Programme
        • Practical Accounting Course
          • Accounting Course in Malayalam
          • Accounting Course in Tamil
          • Tally Course
          • Taxation Course
          • UAE Accounting
          • GST Course
          • Zoho Books Training
          • GST Practitioner Course in Kerala
          • GCC VAT Course
        • ACCA Training Online
          • ACCA Course in Kerala
        • SAP Training Courses
          • SAP FICO Course
          • SAP MM Course
          • SAP SD Training
          • SAP FICO Course in Tamil
          • SAP MM Course in Tamil
        • HR Management Course
        • Performance Marketing Course
        • Mern Stack Developer Course
          • Full Stack Developer Course in Kochi
          • Full Stack Developer Course in Trivandrum
          • Full Stack Developer Course in Calicut
          • Full Stack Developer Course in Pune
          • Full Stack Developer Course in Bangalore
          • Full Stack Developer Course in Hyderabad
          • Full Stack Developer Course in Chennai
          • Full Stack Developer Course in Indore
          • Full Stack Developer Course in Jaipur
          • Full Stack Developer Course in Coimbatore
        • Digital Marketing Training
          • Digital Marketing Course in Kochi
          • Digital Marketing Course in Trivandrum
          • Digital Marketing Course in Calicut
          • Digital Marketing Course in Kollam
          • Digital Marketing Course in Thrissur
          • Digital Marketing Course in Kottayam
          • Digital Marketing Course in Kannur
        • Montessori Teacher Training
          • Montessori Teacher Training in Calicut
          • Montessori Teacher Training in Kochi, Ernakulam
          • Montessori Teacher Training in Trivandrum
          • Montessori Teacher Training in Kollam
          • Montessori Teacher Training in Malayalam
          • Montessori Teacher Training in Kannada
        • Other Courses
          • German Language Course
          • OET Coaching
          • DHA Course
          • MOH Exam Coaching
          • Nurses Recruitment Abroad
          • FMGE Coaching
          • ChatGPT Course
          • Forex Trading Course
          • Yoga Teacher Training Course
          • Diploma in Early Childhood Care and Education
          • Business Administration & Hospital Management Course
          • Hospital and Healthcare Administration
          • AI for Teachers Course
      • Others
        • Railway
          • RRB Technician Notification
          • RRB JE Notification
          • RRB ALP Notification
          • RRB NTPC Notification
          • RRB RPF Notification
          • RRB RPF SI Notification
          • RRB RPF Constable Notification
          • RRB Group D Notification
          • RRB RPSF SI Notification
          • RRB SSE Notification
        • SSC
          • SSC CPO Notification
          • SSC MTS Notification
          • SSC CGL Notification
          • SSC CHSL Notification
          • SSC GD Constable Notification
          • SSC Stenographer Notification
          • SSC JE Notification
          • SSC CAPF Notification
          • SSC JHT Notification
          • Delhi Police Constable Notification
          • Delhi Police SI Notification
        • GATE
        • MAT
        • KMAT
          • KMAT Kerala 2024
        • TET
          • APTET
          • CTET
          • DSSSB
          • Karnataka TET
          • Kerala TET
          • KVS
          • MPTET
          • SUPER TET
          • TNTET
          • TSTET
          • UPTET
        • UPSC
          • UPSC CAPF Notification
          • UPSC CDS Notification
          • UPSC NDA Notification
          • UPSC Civil service Notification
      • Free Learn
        • Free Courses
          • Free Coding Courses
          • Free Accounting Courses
          • Free Digital Marketing Courses
          • Engineering Upskilling Courses
          • Free Hospital Administration Courses
          • Free OET Training
          • Free SAP Courses
          • Free Teachers Training Courses
          • Free Trading Courses
        • Question Answer
        • Aptitude Questions
        • Webinars
      • Test Prep
        • Kerala PSC Coaching
          • KPSC Degree Level Exam Preparation
          • Kerala PSC 12th Level Exam Preparation
          • Kerala PSC 10th Level Exam Preparation
          • KAS Coaching
          • Kerala PSC LDC Coaching
          • Kerala PSC LD Typist Coaching
          • Kerala PSC Fireman Coaching
          • KSFE Assistant Exam Preparation
          • Secretariat Office Attendant Coaching
          • Secretariat Assistant Coaching
          • Kerala PSC SI Exam Coaching
          • Khadi Board LDC Exam Preparation
          • Devaswom Board LDC Coaching
          • University LGS Exam Preparation
          • University Assistant Exam Coaching
          • KPSC Scientific Officer Exam Coaching
          • KPSC Probation Officer Grade II
          • KPSC Food Safety Officer Coaching
          • KWA Sanitary Chemist Coaching
          • KPSC Diary Farm Instructor Exam Coaching
          • Kerala PSC KWA Lab Assistant Exam Coaching
          • Kerala PSC ICDS Supervisor Exam Coaching
          • KPSC Finger Print Searcher Coaching
          • Kerala PSC Welfare Officer Gr. II Exam Coaching
          • KPSC Assistant Dental Surgeon Coaching
        • KPSC Teaching Exams
          • HSA Exam Preparation
          • KPSC HSA Social Science Coaching
          • KPSC HSA Physical Science Coaching
          • KPSC HSA English Coaching
          • KPSC Junior Language Teacher Hindi
          • KTET Coaching
          • SET Coaching
          • LP/UP Assistant Exam Coaching
          • HSST Exam Preparation
          • HSST Commerce Exam Coaching
          • Kerala PSC Lecturer in Diet Coaching
          • KVS PGT/TGT Coaching
        • Kerala PSC Technical Exams Coaching
          • Assistant Engineer Electrical Exam Coaching
          • Assistant Engineer Electronics Coaching
          • Assistant Engineer Mechanical Coaching
          • Kerala PSC Industries Extension Officer Coaching
          • KPSC LSGD AE Exam Coaching
          • KPSC Civil Engineering Exam Coaching
          • KPSC Mechanical Engineering Exam Coaching
          • KPSC Electrical Engineering Exam Coaching
          • KPSC Electronics Engineering Exam Coaching
          • KPSC Technical Computer Science Coaching
          • KPSC Tradesman Turning Coaching
          • Kerala PSC Overseer Exam Coaching
          • KPSC Assistant Town Planner Coaching
          • Lecturer in Polytechnic Electronics Coaching
        • Teaching Exams Coaching
          • CSIR NET Exam Coaching
          • EMRS Coaching
          • CTET Exam Online Coaching
        • IELTS Training Online
        • Bank Exam Coaching Online
          • SEBI Grade A Coaching
          • IBPS SO Online Coaching
          • IBPSC PO Online Coaching
          • IBPSC Clerk Online Coaching
          • SBI PO Coaching
          • SBI Clerk Online Coaching
          • SBI Apprentice Class
          • SBI SO Online Coaching
          • RBI Grade B Coaching
          • RBI Assistant Coaching
          • CSEB Exam Coaching
          • IBPS RRB Coaching
          • IBPS RRB PO Coaching
          • Canara Bank Po Exam Coaching
          • Kerala Gramin Bank Coaching
          • Kerala Bank Exam Coaching
          • JCI Exam Coaching
          • NABARD Grade A Coaching
          • LIC AAO Coaching Online
        • UPSC Online Coaching
          • UPSC CAPF Online Coaching
        • SSC Online Coaching
          • SSC JE Online Coaching
          • SSC CGL Coaching
          • SSC CGL AAO Coaching
          • SSC CGL CBI Inspector Coaching
          • SSC CHSL Coaching
          • SSC MTS Coaching
          • SSC Stenographer Coaching
          • SSC GD Online Coaching
        • RRB Exams Coaching
          • RRB RPF Exam Coaching
          • RRB NTPC Exam Coaching
          • RRB JE Online Coaching
          • RRB JE Electronics Coaching
          • RRB ALP Exam Coaching
          • RRB Technician Exam Coaching
        • CAT Online Coaching
        • CMAT Online Coaching
        • XAT Exam Coaching
        • GATE Online Coaching
          • GATE CE Online Coaching
          • GATE ME Online Coaching
          • GATE EE Online Coaching
        • NMAT Exam Coaching
        • AAI ATC Jr Executive Coaching
        • Cochin Shipyard Executive Trainee Coaching
        • BEL Probationary Engineer Coaching
        • HPCL Junior Executive Coaching

      © 2023 Entri.app - Privacy Policy | Terms of Service

      Chat