Tuple vs List: Difference Between List and Tuple in Python

we have discussed Lists and Tuples. Both the terms have the same purpose of storing the data with a different nature. Then the question that arises here is what is the difference between list and tuple in python? And why it is necessary to know the difference between list and tuple in python? Lists are used to store dynamic values where Tuples can store static values. In real life, we need to store the data in two ways. In the first way, we store the data in a data structure and later access the data and perform operations on the data. For example, the name of the students. We can store the names in a list and can access the names, insert new names, delete particular names.  In a second way, we store the data in a data structure and can access the data only without modifying the data. For example, the name of topper students for a particular year. We can store the topper names in a tuple because once declare, the names will not alter, we can only access the names. So, this is the basic difference between list and tuple in python.

Posted on Nov 25, 2021

More by pratik bais

View profile