{"id":111414,"date":"2026-05-19T12:42:21","date_gmt":"2026-05-19T07:12:21","guid":{"rendered":"https:\/\/www.guvi.in\/blog\/?p=111414"},"modified":"2026-05-19T12:42:22","modified_gmt":"2026-05-19T07:12:22","slug":"enumerate-in-python","status":"publish","type":"post","link":"https:\/\/www.guvi.in\/blog\/enumerate-in-python\/","title":{"rendered":"Enumerate in Python"},"content":{"rendered":"\n<p><strong>Enumerate in Python<\/strong> is a built-in function to <strong>retrieve both the index and the value <\/strong>when looping through a <em>list, tuple, string and other iterable objects<\/em> in Python.<\/p>\n\n\n\n<p>It helps developers to minimise the number of lines of code. This function does not require you to maintain a counter in your loop;<strong> it handles that automatically<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>TL;DR Summary<\/strong><\/h2>\n\n\n\n<ul>\n<li>This blog explains the <strong>Python Enumerate() method<\/strong>, its <strong>syntax, examples, and code flow<\/strong> in simple terms.<\/li>\n<\/ul>\n\n\n\n<ul>\n<li>It shows how enumerate in Python works with <strong>lists, tuples, strings, sets, and dictionaries<\/strong> to build a clear understanding.<\/li>\n<\/ul>\n\n\n\n<ul>\n<li>It helps you write <strong>cleaner loops without a manual counter<\/strong>, making your code easier and more efficient.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Enumerate in Python: Syntax &amp; Example<\/strong><\/h2>\n\n\n\n<p>Let&#8217;s now better understand Enumerate in Python, including its <strong><a href=\"https:\/\/en.wikipedia.org\/wiki\/Syntax_(programming_languages)\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">syntax<\/a><\/strong> and an example.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Syntax:<\/strong><\/h3>\n\n\n\n<p>enumerate(iterable, start=0)<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>a. Parameters<\/strong><\/h4>\n\n\n\n<ul>\n<li><strong>iterable \u2192 <\/strong>The collection you want to loop through, such as a list, tuple,<a href=\"https:\/\/www.guvi.in\/blog\/what-is-a-string-in-python\/\" target=\"_blank\" rel=\"noreferrer noopener\"> <strong>string<\/strong><\/a>, or set.<\/li>\n\n\n\n<li><strong>start=0 \u2192 <\/strong>Defines the starting value of the counter. By default,<a href=\"https:\/\/www.guvi.in\/blog\/indexing-in-python\/\" target=\"_blank\" rel=\"noreferrer noopener\"> <strong>indexing<\/strong><\/a> starts from 0. <em>But you can define any number you choose, and the index counting will begin from that number. (if start=3, count begins from 3)<\/em><\/li>\n<\/ul>\n\n\n\n<p><strong>Also Read:<\/strong><a href=\"https:\/\/www.guvi.in\/blog\/python-how-to-iterate-through-two-lists-in-parallel\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong> <em>How To Iterate Through Two Lists In Parallel?<\/em><\/strong><\/a><\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>b. What does it return:<\/strong><\/h4>\n\n\n\n<p>It returns an <strong>object of index-value pairs,<\/strong> which you can<strong> loop through or convert into a list<\/strong> to see the results directly.<\/p>\n\n\n\n<p><strong><em>Now let&#8217;s look at an example to better understand it.<\/em><\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Example:<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>1. Looping through the enumerate object<\/strong><\/h4>\n\n\n\n<p>names = [&#8220;A&#8221;, &#8220;B&#8221;, &#8220;C&#8221;]<\/p>\n\n\n\n<p>result = enumerate(names)<\/p>\n\n\n\n<p>for index, value in result:<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;print(index, value)<\/p>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<p>0 A<\/p>\n\n\n\n<p>1 B<\/p>\n\n\n\n<p>2 C<\/p>\n\n\n\n<h5 class=\"wp-block-heading\"><strong><em>Code Explanation:<\/em><\/strong><\/h5>\n\n\n\n<ul>\n<li>You first create an <strong>enumerate object<\/strong> from the list, which stores <strong>index-value pairs<\/strong>.<\/li>\n\n\n\n<li>Then the<a href=\"https:\/\/www.guvi.in\/blog\/what-are-python-loops\/\" target=\"_blank\" rel=\"noreferrer noopener\"> <strong>loop<\/strong><\/a> goes through each pair one by one, separating the <strong>index<\/strong> and the <strong>value<\/strong> each time and printing them.<\/li>\n\n\n\n<li>So you see the output step by step instead of all at once.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>2. Converting to a list<\/strong><\/h4>\n\n\n\n<p>names = [&#8220;A&#8221;, &#8220;B&#8221;, &#8220;C&#8221;]<\/p>\n\n\n\n<p>result = enumerate(names)<\/p>\n\n\n\n<p>print(list(result))<\/p>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<p>[(0, &#8216;A&#8217;), (1, &#8216;B&#8217;), (2, &#8216;C&#8217;)]<\/p>\n\n\n\n<h5 class=\"wp-block-heading\"><strong><em>Code Explanation:<\/em><\/strong><\/h5>\n\n\n\n<ul>\n<li>Here, the <strong>enumerate object<\/strong> is converted into a <strong>list<\/strong>, which forces<a href=\"https:\/\/www.guvi.in\/blog\/what-is-python-used-for\/\" target=\"_blank\" rel=\"noreferrer noopener\"> <strong>Python<\/strong><\/a> to show all the stored <strong>index-value pairs together<\/strong>.<\/li>\n\n\n\n<li>Instead of looping one by one, you directly get the full collection of pairs in a single output.<\/li>\n<\/ul>\n\n\n\n<p><em>Begin your coding journey with <\/em><strong><em>HCL GUVI&#8217;s free Python resource <\/em><\/strong><em>and cover all the essential topics from variables and functions, operators, to OOPs techniques with practical insights:<\/em><a href=\"https:\/\/www.guvi.in\/mlp\/python-ebook?utm_source=blog&amp;utm_medium=hyperlink&amp;utm_campaign=Enumerate+in+Python+\" target=\"_blank\" rel=\"noreferrer noopener\"><em> <\/em><strong>Python eBook<\/strong><\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Enumerate Method Examples with Different Iterable Objects in Python<\/strong><\/h2>\n\n\n\n<p>These are the following with <strong>list,<\/strong><a href=\"https:\/\/www.guvi.in\/blog\/what-is-a-tuple-in-python\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong> tuple<\/strong><\/a><strong>, string, set, and<\/strong><a href=\"https:\/\/www.guvi.in\/blog\/what-is-a-dictionary-in-python\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong> dictionary<\/strong><\/a><strong> <\/strong>using enumerate() in Python:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1. List<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Code:<\/strong><\/h4>\n\n\n\n<p>fruits = [&#8220;Apple&#8221;, &#8220;Banana&#8221;, &#8220;Mango&#8221;]<\/p>\n\n\n\n<p>for i, item in enumerate(fruits):<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;print(i, item)<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Output:<\/strong><\/h4>\n\n\n\n<p>0 Apple&nbsp;&nbsp;<\/p>\n\n\n\n<p>1 Banana&nbsp;&nbsp;<\/p>\n\n\n\n<p>2 Mango<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. Tuple<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Code:<\/strong><\/h4>\n\n\n\n<p>colors = (&#8220;Red&#8221;, &#8220;Green&#8221;, &#8220;Blue&#8221;)<\/p>\n\n\n\n<p>for i, item in enumerate(colors):<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;print(i, item)<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Output:<\/strong><\/h4>\n\n\n\n<p>0 Red&nbsp;&nbsp;<\/p>\n\n\n\n<p>1 Green&nbsp;&nbsp;<\/p>\n\n\n\n<p>2 Blue<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. String<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Code:<\/strong><\/h4>\n\n\n\n<p>text = &#8220;Hello&#8221;<\/p>\n\n\n\n<p>for i, char in enumerate(text):<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;print(i, char)<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Output:<\/strong><\/h4>\n\n\n\n<p>0 H&nbsp;&nbsp;<\/p>\n\n\n\n<p>1 e&nbsp;&nbsp;<\/p>\n\n\n\n<p>2 l&nbsp;&nbsp;<\/p>\n\n\n\n<p>3 l&nbsp;&nbsp;<\/p>\n\n\n\n<p>4 o<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>4. Set<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Code:<\/strong><\/h4>\n\n\n\n<p>numbers = {10, 20, 30}<\/p>\n\n\n\n<p>for i, num in enumerate(numbers):<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;print(i, num)<\/p>\n\n\n\n<p><strong>Output (order may change):<\/strong><\/p>\n\n\n\n<p>0 10&nbsp;&nbsp;<\/p>\n\n\n\n<p>1 20&nbsp;&nbsp;<\/p>\n\n\n\n<p>2 30<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>5. Dictionary (keys only)<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Code:<\/strong><\/h4>\n\n\n\n<p>data = {&#8220;name&#8221;: &#8220;A&#8221;, &#8220;age&#8221;: 20, &#8220;city&#8221;: &#8220;Delhi&#8221;}<\/p>\n\n\n\n<p>for i, key in enumerate(data):<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;print(i, key)<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Output:<\/strong><\/h4>\n\n\n\n<p>0 name&nbsp;&nbsp;<\/p>\n\n\n\n<p>1 age&nbsp;&nbsp;<\/p>\n\n\n\n<p>2 city<\/p>\n\n\n\n<p>If you\u2019re waiting for a sign to start coding, this is it. <strong>HCL GUVI&#8217;s<\/strong><a href=\"https:\/\/www.guvi.in\/courses\/programming\/python-zero-to-hero\/?utm_source=blog&amp;utm_medium=hyperlink&amp;utm_campaign=Enumerate+in+Python+\" target=\"_blank\" rel=\"noreferrer noopener\"><strong> Python Zero to Hero Course<\/strong><\/a> takes you from beginner to job-ready with Python, step by step, in a simple way. <strong><em>Just start\u2014you\u2019ll figure the rest out along the way!<\/em><\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<p>To wrap up, the <strong>Enumerate <\/strong>in Python <strong>returns the index and value of each item<\/strong> in a loop over an iterable, <em>such as a list, tuple, string, set, or dictionary<\/em>. It is mostly used because it helps avoid manual counter creation, making the code cleaner, modular, and less error-prone.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>FAQs<\/strong><\/h2>\n\n\n<div id=\"rank-math-faq\" class=\"rank-math-block\">\n<div class=\"rank-math-list \">\n<div id=\"faq-question-1779168542817\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><strong>Why does Enumerate in Python return an object instead of a list?<\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>It returns an enumerate object to use memory efficiently and generate index-value pairs only when needed.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1779168544398\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><strong>Can Enumerate in Python be used without a loop?<\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>It creates an object, but it becomes useful only when converted to a list or used inside a loop.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1779168546121\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><strong>Does Enumerate in Python change the original data?<\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>It only reads the index and values, so the original data remains unchanged.<\/p>\n\n<\/div>\n<\/div>\n<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Enumerate in Python is a built-in function to retrieve both the index and the value when looping through a list, tuple, string and other iterable objects in Python. It helps developers to minimise the number of lines of code. This function does not require you to maintain a counter in your loop; it handles that [&hellip;]<\/p>\n","protected":false},"author":64,"featured_media":111449,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[717],"tags":[],"views":"35","authorinfo":{"name":"Abhishek Pati","url":"https:\/\/www.guvi.in\/blog\/author\/abhishek-pati\/"},"thumbnailURL":"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/05\/Enumerate-in-Python-300x116.webp","jetpack_featured_media_url":"https:\/\/www.guvi.in\/blog\/wp-content\/uploads\/2026\/05\/Enumerate-in-Python.webp","_links":{"self":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/111414"}],"collection":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/users\/64"}],"replies":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/comments?post=111414"}],"version-history":[{"count":4,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/111414\/revisions"}],"predecessor-version":[{"id":111452,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/posts\/111414\/revisions\/111452"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/media\/111449"}],"wp:attachment":[{"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/media?parent=111414"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/categories?post=111414"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.guvi.in\/blog\/wp-json\/wp\/v2\/tags?post=111414"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}