

{"id":5703,"date":"2018-01-06T09:43:47","date_gmt":"2018-01-06T09:43:47","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=5703"},"modified":"2026-04-21T14:48:55","modified_gmt":"2026-04-21T09:18:55","slug":"python-tuples-vs-lists","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/python-tuples-vs-lists\/","title":{"rendered":"Python Tuples vs Lists &#8211; Comparison Between Lists and Tuples"},"content":{"rendered":"<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:149,&quot;href&quot;:&quot;https:\\\/\\\/www.python.org&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20251206090101\\\/https:\\\/\\\/www.python.org\\\/&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2025-12-06 12:20:59&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-09 12:44:48&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-12 13:49:48&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-15 14:13:48&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-18 15:26:07&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-21 17:05:18&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-24 19:33:20&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-28 02:44:18&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2025-12-31 04:43:13&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-03 07:01:16&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-06 07:15:14&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-09 07:16:21&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-12 10:01:16&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-15 10:07:06&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-18 10:11:43&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-21 10:20:21&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-24 10:47:21&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-27 10:58:10&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-01-30 10:59:29&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-02 12:28:37&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-02-05 13:05:41&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-08 15:11:10&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-11 15:46:29&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-14 17:21:34&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-17 18:37:27&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-20 18:52:05&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-23 19:52:29&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-27 01:02:50&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-02 03:50:52&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-05 05:18:10&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-08 06:18:52&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-11 07:24:15&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-14 08:33:37&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-03-17 08:58:17&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-20 12:26:41&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-23 14:32:34&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-26 16:21:46&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-29 17:22:50&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-01 18:18:54&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-04 18:27:04&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-08 02:33:55&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-11 04:53:57&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-14 06:48:30&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-17 07:17:55&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-20 07:32:43&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-23 09:34:41&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-26 10:13:17&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-04-29 10:35:31&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-02 11:50:34&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-05 12:07:03&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-08 13:08:24&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-11 14:46:17&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-14 21:24:09&quot;,&quot;http_code&quot;:404},{&quot;date&quot;:&quot;2026-05-18 03:08:37&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-21 06:27:39&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-24 07:06:36&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-27 07:30:50&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-05-30 08:47:47&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-02 09:37:18&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-05 09:43:29&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-08 10:40:15&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-06-11 10:49:02&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-11 10:49:02&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;}]'><\/div>\n<p>In our previous Python tutorials, we\u2019ve seen <a href=\"https:\/\/data-flair.training\/blogs\/python-tuples-syntax-examples\/\">tuples in python<\/a> and <a href=\"https:\/\/data-flair.training\/blogs\/python-lists-examples\/\">lists in python<\/a>. Both are heterogeneous collections of Python objects. But which one do you choose when you need to store a collection? To answer this question, we first get a little deeper into the two constructs, and then we will study the comparison between Python tuples vs lists.<\/p>\n<p>So, let&#8217;s start\u00a0Python Tuples vs Lists Tutorial.<\/p>\n<h3>Revision of Tuples in Python<\/h3>\n<p>Before comparing tuples and lists, we should review them. First, we look at a tuple.<\/p>\n<p>A tuple is a collection of values, and we declare it using parentheses. However, we can also use tuple packing to do the same, and unpacking to assign its values to a sequence of variables.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; numbers=(1,2,'three')\r\n&gt;&gt;&gt; numbers=4,5,6\r\n&gt;&gt;&gt; a,b,c=numbers\r\n&gt;&gt;&gt; print(numbers,a,b,c,type(numbers))<\/pre>\n<p>(4, 5, 6) 4 5 6 &lt;class &#8216;tuple&#8217;&gt;<\/p>\n<p>A tuple is returned when we call the method localtime().<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; import time\r\n&gt;&gt;&gt; time.localtime()<\/pre>\n<p>time.struct_time(tm_year=2018, tm_mon=1, tm_mday=1, tm_hour=23, tm_min=1, tm_sec=59, tm_wday=0, tm_yday=1, tm_isdst=0)<\/p>\n<p>To access a tuple, we use indexing, which begins at 0.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; numbers[1]<\/pre>\n<p>5<\/p>\n<p>We can also slice it to retrieve a part of it.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; numbers[:-1]<\/pre>\n<p>(4, 5)<\/p>\n<p>Finally, we can delete an entire tuple.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; del numbers\r\n&gt;&gt;&gt; numbers<\/pre>\n<p>Traceback (most recent call last):<\/p>\n<p>File &#8220;&lt;pyshell#40&gt;&#8221;, line 1, in &lt;module&gt;<\/p>\n<p>numbers<\/p>\n<p>NameError: name &#8216;numbers&#8217; is not defined<\/p>\n<p>We also learned some functions and methods on <a href=\"https:\/\/data-flair.training\/blogs\/python-tuples-syntax-examples\/\">tuples<\/a> and <a href=\"https:\/\/data-flair.training\/blogs\/python-lists-examples\/\">lists<\/a>. You must read our tutorials on them for more insight.<\/p>\n<h3>Revision of Lists in Python<\/h3>\n<p>Unlike in C++, we don\u2019t have arrays to work with in Python. Here, we have a list instead.<\/p>\n<p>We create lists using square brackets.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; colors=['red','blue','green']<\/pre>\n<p>We can slice lists, too.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; colors[-2:]<\/pre>\n<p>[&#8216;blue&#8217;, &#8216;green&#8217;]<\/p>\n<p>Then, we learned how to reassign and delete them.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; colors[0]='pink'\r\n&gt;&gt;&gt; colors<\/pre>\n<p>[&#8216;pink&#8217;, &#8216;blue&#8217;, &#8216;green&#8217;]<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; del colors[0]\r\n&gt;&gt;&gt; colors[0]<\/pre>\n<p>&#8216;blue&#8217;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; del colors\r\n&gt;&gt;&gt; colors<\/pre>\n<p>Traceback (most recent call last):<\/p>\n<p>File &#8220;&lt;pyshell#52&gt;&#8221;, line 1, in &lt;module&gt;<\/p>\n<p>colors<\/p>\n<p>NameError: name &#8216;colors&#8217; is not defined<\/p>\n<p>Now that we\u2019ve refreshed our memories, we can proceed to differentiate between Python tuples and lists.<\/p>\n<h3>Python tuples vs lists &#8211; Mutability<\/h3>\n<p>The major difference between tuples and lists is that a list is mutable, whereas a tuple is immutable. This means that a list can be changed, but a tuple cannot.<\/p>\n<h4>a. A List is Mutable in Python<\/h4>\n<p>Let\u2019s first see lists. Let\u2019s take a new list for exemplar purposes.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; list1=[0,1,2,3,4,5,6,7]<\/pre>\n<p>Now, first, we\u2019ll try reassigning an element of a list. Let\u2019s reassign the second element to hold the value 3.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; list1[1]=3\r\n&gt;&gt;&gt; list1<\/pre>\n<p>[0, 3, 2, 3, 4, 5, 6, 7]<\/p>\n<p>Again, let\u2019s see how we can reassign the entire list.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; list1=[7,6,5,4,3,2,1,0]\r\n&gt;&gt;&gt; list1<\/pre>\n<p>[7, 6, 5, 4, 3, 2, 1, 0]<\/p>\n<p>It worked great.<\/p>\n<p>Now, we will delete just one element from the list.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; del list1[1]\r\n&gt;&gt;&gt; list1<\/pre>\n<p>[7, 5, 4, 3, 2, 1, 0]<\/p>\n<p>This was easy, but could we delete a slice of the list? Let\u2019s try it.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; del list1[3:]\r\n&gt;&gt;&gt; list1<\/pre>\n<p>[7, 5, 4]<\/p>\n<p>We can access a slice the same way. Can we reassign a slice?<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; nums=[1,2,3,4,5]\r\n&gt;&gt;&gt; nums[1:3]=[6,7,8]\r\n&gt;&gt;&gt; nums<\/pre>\n<p>[1, 6, 7, 8, 4, 5]<\/p>\n<p>Indeed, we can. Finally, let\u2019s try deleting the entire list.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; del list1\r\n&gt;&gt;&gt; list1<\/pre>\n<p>Traceback (most recent call last):<\/p>\n<p>File &#8220;&lt;pyshell#67&gt;&#8221;, line 1, in &lt;module&gt;<\/p>\n<p>list1<\/p>\n<p>NameError: name &#8216;list1&#8217; is not defined<\/p>\n<p>The list doesn\u2019t exist anymore.<\/p>\n<h4>b. A Tuple is Immutable in Python<\/h4>\n<p>Now, let\u2019s try doing the same things to a tuple. We know that a tuple is immutable, so some of these operations shouldn\u2019t work. We\u2019ll take a new tuple for this purpose.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; mytuple=0,1,2,3,4,5,6,7<\/pre>\n<p>First, let\u2019s try reassigning the second element.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; mytuple[1]=3<\/pre>\n<p>Traceback (most recent call last):<\/p>\n<p>File &#8220;&lt;pyshell#70&gt;&#8221;, line 1, in &lt;module&gt;<\/p>\n<p>mytuple[1]=3<\/p>\n<p>TypeError: &#8216;tuple&#8217; object does not support item assignment<\/p>\n<p>As you can see, a tuple doesn\u2019t support item assignment.<\/p>\n<p>However, we can reassign an entire tuple.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; mytuple=2,3,4,5,6\r\n&gt;&gt;&gt; mytuple<\/pre>\n<p>(2, 3, 4, 5, 6)<\/p>\n<p>Next, let\u2019s try slicing a tuple to access or delete it.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; mytuple[3:]<\/pre>\n<p>(5, 6)<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; del mytuple[3:]<\/pre>\n<p>Traceback (most recent call last):<\/p>\n<p>File &#8220;&lt;pyshell#74&gt;&#8221;, line 1, in &lt;module&gt;<\/p>\n<p>del mytuple[3:]<\/p>\n<p>TypeError: &#8216;tuple&#8217; object does not support item deletion<\/p>\n<p>As is visible, we can slice it to access it, but we can\u2019t delete a slice. This is because it is immutable.<\/p>\n<p>Can we delete a single element?<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; del\u00a0 mytuple[3]<\/pre>\n<p>Traceback (most recent call last):<\/p>\n<p>File &#8220;&lt;pyshell#75&gt;&#8221;, line 1, in &lt;module&gt;<\/p>\n<p>del\u00a0 mytuple[3]<\/p>\n<p>TypeError: &#8216;tuple&#8217; object doesn&#8217;t support item deletion<\/p>\n<p>Apparently, the answer is no.<\/p>\n<p>Finally, let\u2019s try deleting the entire tuple.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; del\u00a0 mytuple\r\n&gt;&gt;&gt; mytuple<\/pre>\n<p>Traceback (most recent call last):<\/p>\n<p>File &#8220;&lt;pyshell#77&gt;&#8221;, line 1, in &lt;module&gt;<\/p>\n<p>mytuple<\/p>\n<p>NameError: name &#8216;mytuple&#8217; is not defined<\/p>\n<p>So, here, we conclude that you can slice a tuple, reassign it whole, or delete it whole.<\/p>\n<p>But you cannot delete or reassign just a few elements or a slice.<\/p>\n<p>Let us proceed with more differences between Python tuples vs lists.<\/p>\n<h3>Functions in Python<\/h3>\n<p>Some <a href=\"https:\/\/data-flair.training\/blogs\/python-functions\/\">python functions<\/a> apply on both, these are- len(), max(), min(), sum(), any(), all(), sorted(). We\u2019ll take just one example here for both containers.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; max((1,3,-1))<\/pre>\n<p>3<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; max([1,3,-1])<\/pre>\n<p>3<\/p>\n<h3>Methods in Python<\/h3>\n<p>Lists and tuples share the index() and count() methods. But other than those, there are a few methods that apply to lists. These are- append(), insert(), remove(), pop(), clear(), sort(), and reverse(). Let\u2019s take an example of one of these.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; [1,3,2].index(3)<\/pre>\n<p>1<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; (1,3,2).index(3)<\/pre>\n<p>1<br \/>\nTo get an insight into all of these methods and functions we mentioned, you should refer to our articles on <a href=\"https:\/\/data-flair.training\/blogs\/python-lists-examples\/\">lists<\/a> and <a href=\"https:\/\/data-flair.training\/blogs\/python-tuples-syntax-examples\/\">tuples<\/a>.<\/p>\n<h3>Tuples in a List<\/h3>\n<p>We can store tuples in a list when we want to.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; mylist=[(1,2,3),(4,5,6)]\r\n&gt;&gt;&gt; type(mylist)<\/pre>\n<p>&lt;class &#8216;list&#8217;&gt;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; type(mylist[1])<\/pre>\n<p>&lt;class &#8216;tuple&#8217;&gt;<\/p>\n<p>But when would we need to do this? Take an example.<\/p>\n<p>[(1, &#8216;ABC&#8217;), (2, &#8216;DEF&#8217;), (3, &#8216;GHI&#8217;)]<\/p>\n<h3>Lists in a Tuple<\/h3>\n<p>Likewise, we can also use a tuple to store lists.<\/p>\n<p><strong>When lists in a tuple can be used:<\/strong><\/p>\n<ul>\n<li><strong>Group of data:<\/strong> It can be used when you have a specific group of data, whereas some remain constant.<\/li>\n<li><strong>Data integrity:<\/strong> The structure of data cannot be changed, even if the individual value is changed.<\/li>\n<\/ul>\n<p>Let\u2019s see how.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; mytuple=([1,2],[3,4],[5,6])<\/pre>\n<h3>Nested Tuples in Python<\/h3>\n<p>A tuple may hold more tuples, and this can go on in more than two dimensions.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; mytuple=((1,2),(3,(4,5),(6,(7,(8,9)))))\r\n<\/pre>\n<p>To access the element with the value 8, we write the following code.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; mytuple[1][2][1][1][0]\r\n<\/pre>\n<p>8<\/p>\n<h3>Nested Lists in Python<\/h3>\n<p>Similarly, a list may hold more lists, in as many dimensions as you want.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; mylist=[[1,2],[3,4]]\r\n&gt;&gt;&gt; myotherlist=[[1,2],[3,[4,5]]]<\/pre>\n<p>To access the element with the value 5, we write the following code.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; myotherlist[1][1][1]\r\n<\/pre>\n<p>5<\/p>\n<h3>When to Use Which<\/h3>\n<p>Use a tuple when you know what information goes in the container that it is. For example, when you want to store a person\u2019s credentials for your website.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; person=('ABC','admin','12345')\r\n<\/pre>\n<p>But when you want to store similar elements, like in an array in C++, you should use a list.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">&gt;&gt;&gt; groceries=['bread','butter','cheese']\r\n<\/pre>\n<p>Note that this does not say that a list can only contain homogeneous values. Also, you can\u2019t use a list as a key for a dictionary. This is because only immutable values can be hashed. Hence, we can only set immutable values like tuples as keys. But if you still want to use a list as a key, you must turn it into a tuple first.<\/p>\n<p>So, this was all about\u00a0Python Tuples vs Lists. Hope you like our explanation.<\/p>\n<h3>Conclusion<\/h3>\n<p>Lists and tuples may look alike\u2014both hold ordered items you reach by index\u2014but their intent differs. A list is built for change: append movies to a watchlist, delete a wrong entry, or sort scores after each new game. Its mutable design makes these edits easy but forces Python to copy and resize memory blocks as it grows. A tuple, by contrast, freezes its items forever, which lets the interpreter store it in a compact, read-only area and trust it as a key inside sets or dictionaries.<\/p>\n<p>This means tuples run faster in loops and use less RAM on large data. When your data is a record\u2014day, month, year\u2014choose a tuple for safety. When it is a collection that will evolve\u2014cart items, search results\u2014choose a list. Picking wisely guards against bugs, boosts speed, and tells future readers exactly what kind of data story you plan to write.<\/p>\n<p>What do you think? Tell us in the comments.<\/p>\n<p><strong><a href=\"https:\/\/www.python.org\/\">Reference<\/a><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In our previous Python tutorials, we\u2019ve seen tuples in python and lists in python. Both are heterogeneous collections of Python objects. But which one do you choose when you need to store a collection?&#46;&#46;&#46;<\/p>\n","protected":false},"author":5,"featured_media":35820,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[2756,10459,10649,10650,10901,10902],"class_list":["post-5703","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-comparison-between-python-lists-and-tuples","tag-python-data-structures","tag-python-lists","tag-python-lists-vs-tuples","tag-python-tuples","tag-python-tuples-vs-lists"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Python Tuples vs Lists - Comparison Between Lists and Tuples - DataFlair<\/title>\n<meta name=\"description\" content=\"Python tuples vs lists - Understand what is tuple in python, what is list in python and which to use when with comparison between python lists and tuples.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/python-tuples-vs-lists\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Tuples vs Lists - Comparison Between Lists and Tuples - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Python tuples vs lists - Understand what is tuple in python, what is list in python and which to use when with comparison between python lists and tuples.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/python-tuples-vs-lists\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-01-06T09:43:47+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-21T09:18:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Python-Tuples-vs-Lists-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python Tuples vs Lists - Comparison Between Lists and Tuples - DataFlair","description":"Python tuples vs lists - Understand what is tuple in python, what is list in python and which to use when with comparison between python lists and tuples.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/python-tuples-vs-lists\/","og_locale":"en_US","og_type":"article","og_title":"Python Tuples vs Lists - Comparison Between Lists and Tuples - DataFlair","og_description":"Python tuples vs lists - Understand what is tuple in python, what is list in python and which to use when with comparison between python lists and tuples.","og_url":"https:\/\/data-flair.training\/blogs\/python-tuples-vs-lists\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2018-01-06T09:43:47+00:00","article_modified_time":"2026-04-21T09:18:55+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Python-Tuples-vs-Lists-1.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/python-tuples-vs-lists\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/python-tuples-vs-lists\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823"},"headline":"Python Tuples vs Lists &#8211; Comparison Between Lists and Tuples","datePublished":"2018-01-06T09:43:47+00:00","dateModified":"2026-04-21T09:18:55+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-tuples-vs-lists\/"},"wordCount":1303,"commentCount":9,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-tuples-vs-lists\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Python-Tuples-vs-Lists-1.jpg","keywords":["comparison between python lists and tuples","python data structures","python lists","python lists vs tuples","python tuples","python tuples vs lists"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/python-tuples-vs-lists\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/python-tuples-vs-lists\/","url":"https:\/\/data-flair.training\/blogs\/python-tuples-vs-lists\/","name":"Python Tuples vs Lists - Comparison Between Lists and Tuples - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-tuples-vs-lists\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-tuples-vs-lists\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Python-Tuples-vs-Lists-1.jpg","datePublished":"2018-01-06T09:43:47+00:00","dateModified":"2026-04-21T09:18:55+00:00","description":"Python tuples vs lists - Understand what is tuple in python, what is list in python and which to use when with comparison between python lists and tuples.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/python-tuples-vs-lists\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/python-tuples-vs-lists\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/python-tuples-vs-lists\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Python-Tuples-vs-Lists-1.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Python-Tuples-vs-Lists-1.jpg","width":1200,"height":628,"caption":"Python Tuples vs Lists - Comparison Between Lists and Tuples"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/python-tuples-vs-lists\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Python Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/python\/"},{"@type":"ListItem","position":3,"name":"Python Tuples vs Lists &#8211; Comparison Between Lists and Tuples"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team creates expert-level guides on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our goal is to empower learners with easy-to-understand content. Explore our resources for career growth and practical learning.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam1\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/5703","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=5703"}],"version-history":[{"count":10,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/5703\/revisions"}],"predecessor-version":[{"id":147746,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/5703\/revisions\/147746"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/35820"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=5703"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=5703"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=5703"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}