{"id":1451,"date":"2023-05-21T08:21:57","date_gmt":"2023-05-21T08:21:57","guid":{"rendered":"https:\/\/itnotes.apjsoftwares.com\/?p=1451"},"modified":"2023-05-21T08:21:57","modified_gmt":"2023-05-21T08:21:57","slug":"what-is-enumerate-in-python","status":"publish","type":"post","link":"https:\/\/itnotes.apjsoftwares.in\/index.php\/2023\/05\/21\/what-is-enumerate-in-python\/","title":{"rendered":"What is enumerate() in Python?"},"content":{"rendered":"\n<p>Enumerate() in Python\u00a0is a built-in function used for assigning an index to each item of the iterable object. It adds a loop on the iterable objects while keeping track of the current item and returns the object in an enumerable form. This object can be used in a for loop to convert it into a list by using list() method.<\/p>\n\n\n\n<p><strong>Example of enumerate() is as follows:<\/strong><\/p>\n\n\n\n<p>Suppose we want to do numbering for our month ( Jan, Feb, Marc, \u2026.June), so we declare the variable i that enumerate the numbers while m will print the number of month in list.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#use a for loop over a collection\nMonths = [\"Jan\",\"Feb\",\"Mar\",\"April\",\"May\",\"June\"]\nfor i, m in enumerate (Months):\n        print(i,m)\n        \n# use the break and continue statements\n        \n        #for x in range (10,20):\n        #if (x == 15): break\n        #if (x % 5 == 0) : continue\n        #print x<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Enumerate() in Python\u00a0is a built-in function used for assigning an index to each item of&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[20],"tags":[],"_links":{"self":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/1451"}],"collection":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/comments?post=1451"}],"version-history":[{"count":1,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/1451\/revisions"}],"predecessor-version":[{"id":1452,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/1451\/revisions\/1452"}],"wp:attachment":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/media?parent=1451"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/categories?post=1451"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/tags?post=1451"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}