{"id":18018,"date":"2021-11-11T15:54:30","date_gmt":"2021-11-11T10:24:30","guid":{"rendered":"https:\/\/tutorial.eyehunts.com\/?p=18018"},"modified":"2023-03-17T18:12:16","modified_gmt":"2023-03-17T12:42:16","slug":"iterate-over-list-of-strings-python-example-code","status":"publish","type":"post","link":"https:\/\/tutorial.eyehunts.com\/python\/iterate-over-list-of-strings-python-example-code\/","title":{"rendered":"Iterate over list of strings Python | Example code"},"content":{"rendered":"\n<p>Using <a href=\"https:\/\/tutorial.eyehunts.com\/python\/python-for-loops-tutorial-example\/\">For loop<\/a>, <a href=\"https:\/\/tutorial.eyehunts.com\/python\/python-while-loop-statements\/\">while loop<\/a> or <a href=\"https:\/\/tutorial.eyehunts.com\/python\/python-enumerate-function-example\/\">enumerate() function <\/a>can easily Iterate over a list of strings in Python. You can use list comprehension to create a new list based on the original list of strings.<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Example code Iterate over a <\/strong>list of strings in <strong>Python<\/strong><\/h2>\n\n\n\n<p>Simple example codes multiple ways to iterate over a list in Python.<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>Using For loop<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>list = &#91;'Aa', 'Bb', 'Cc']\n\n# Using for loop\nfor i in list:\n    print(i)\n<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong>:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"210\" height=\"152\" src=\"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/11\/Iterate-over-list-of-strings-Python.jpg?resize=210%2C152&#038;ssl=1\" alt=\"Iterate over list of strings Python\" class=\"wp-image-22084\"\/><\/figure><\/div>\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>Using while loop<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>list1 = &#91;'Aa', 'Bb', 'Cc']\n\nlength = len(list1)\ni = 0\n\n# Iterating using while loop\nwhile i &lt; length:\n    print(list1&#91;i])\n    i += 1\n<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong>: <\/p>\n\n\n\n<p>Aa<br>Bb<br>Cc<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>Using list comprehension<\/strong><\/p>\n\n\n\n<p>This is a single-line solution.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>list1 = &#91;'Hello', 'Loop']\n\n&#91;print(i) for i in list1]\n<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong>: <\/p>\n\n\n\n<p>Hello<br>Loop<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>Using enumerate() function<\/strong><\/p>\n\n\n\n<p>With this method, you can get the index value on <a href=\"https:\/\/tutorial.eyehunts.com\/python\/python-skip-to-next-iteration-example-code\/\">Iteration <\/a>over the list of strings in Python.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>list1 = &#91;'Hello', 'Loop']\n\nfor i, val in enumerate(list1):\n    print(i, \",\", val)\n<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong>: <\/p>\n\n\n\n<p>0 , Hello<br>1 , Loop<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Do comment if you have any doubts or suggestions on this Python Iterate list topic.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong>Note:<\/strong> IDE:&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/www.jetbrains.com\/pycharm\/\" target=\"_blank\">PyCharm<\/a>&nbsp;2021.3.3 (Community Edition)<\/p><p>Windows 10<\/p><p><strong>Python 3.10.1<\/strong><\/p><p>All<strong>&nbsp;Python Examples&nbsp;are in&nbsp;Python&nbsp;3<\/strong>, so Maybe its different from python 2 or upgraded versions.<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Using For loop, while loop or enumerate() function can easily Iterate over a list of strings in Python. You can use list comprehension to create a new list based on the original list of strings. Example code Iterate over a list of strings in Python Simple example codes multiple ways to iterate over a list&hellip;&nbsp;<a href=\"https:\/\/tutorial.eyehunts.com\/python\/iterate-over-list-of-strings-python-example-code\/\" rel=\"bookmark\">Read More &raquo;<span class=\"screen-reader-text\">Iterate over list of strings Python | Example code<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[30],"tags":[83,36,98],"post_series":[],"class_list":["post-18018","post","type-post","status-publish","format-standard","hentry","category-python","tag-python-list","tag-python-loops","tag-python-string"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.1.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Iterate over list of strings Python | Example code - EyeHunts<\/title>\n<meta name=\"description\" content=\"Using For loop, while loop or enumerate() function can easily Iterate over a list of strings in Python. You can use list comprehension to...\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/tutorial.eyehunts.com\/python\/iterate-over-list-of-strings-python-example-code\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Iterate over list of strings Python | Example code - EyeHunts\" \/>\n<meta property=\"og:description\" content=\"Using For loop, while loop or enumerate() function can easily Iterate over a list of strings in Python. You can use list comprehension to...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/tutorial.eyehunts.com\/python\/iterate-over-list-of-strings-python-example-code\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:published_time\" content=\"2021-11-11T10:24:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-03-17T12:42:16+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/11\/Iterate-over-list-of-strings-Python.jpg\" \/>\n<meta name=\"author\" content=\"Rohit\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rohit\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/iterate-over-list-of-strings-python-example-code\/\",\"url\":\"https:\/\/tutorial.eyehunts.com\/python\/iterate-over-list-of-strings-python-example-code\/\",\"name\":\"Iterate over list of strings Python | Example code - EyeHunts\",\"isPartOf\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/iterate-over-list-of-strings-python-example-code\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/iterate-over-list-of-strings-python-example-code\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/11\/Iterate-over-list-of-strings-Python.jpg\",\"datePublished\":\"2021-11-11T10:24:30+00:00\",\"dateModified\":\"2023-03-17T12:42:16+00:00\",\"author\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1\"},\"description\":\"Using For loop, while loop or enumerate() function can easily Iterate over a list of strings in Python. You can use list comprehension to...\",\"breadcrumb\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/iterate-over-list-of-strings-python-example-code\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/tutorial.eyehunts.com\/python\/iterate-over-list-of-strings-python-example-code\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/iterate-over-list-of-strings-python-example-code\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/11\/Iterate-over-list-of-strings-Python.jpg?fit=210%2C152&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/11\/Iterate-over-list-of-strings-Python.jpg?fit=210%2C152&ssl=1\",\"width\":210,\"height\":152},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/iterate-over-list-of-strings-python-example-code\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/tutorial.eyehunts.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Iterate over list of strings Python | Example code\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/#website\",\"url\":\"https:\/\/tutorial.eyehunts.com\/\",\"name\":\"Tutorial\",\"description\":\"By EyeHunts\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/tutorial.eyehunts.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1\",\"name\":\"Rohit\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777374971\",\"contentUrl\":\"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777374971\",\"caption\":\"Rohit\"},\"description\":\"Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology &amp; like learning technical.\",\"url\":\"https:\/\/tutorial.eyehunts.com\/author\/rohit\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Iterate over list of strings Python | Example code - EyeHunts","description":"Using For loop, while loop or enumerate() function can easily Iterate over a list of strings in Python. You can use list comprehension to...","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:\/\/tutorial.eyehunts.com\/python\/iterate-over-list-of-strings-python-example-code\/","og_locale":"en_US","og_type":"article","og_title":"Iterate over list of strings Python | Example code - EyeHunts","og_description":"Using For loop, while loop or enumerate() function can easily Iterate over a list of strings in Python. You can use list comprehension to...","og_url":"https:\/\/tutorial.eyehunts.com\/python\/iterate-over-list-of-strings-python-example-code\/","og_site_name":"Tutorial","article_published_time":"2021-11-11T10:24:30+00:00","article_modified_time":"2023-03-17T12:42:16+00:00","og_image":[{"url":"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/11\/Iterate-over-list-of-strings-Python.jpg","type":"","width":"","height":""}],"author":"Rohit","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Rohit","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/tutorial.eyehunts.com\/python\/iterate-over-list-of-strings-python-example-code\/","url":"https:\/\/tutorial.eyehunts.com\/python\/iterate-over-list-of-strings-python-example-code\/","name":"Iterate over list of strings Python | Example code - EyeHunts","isPartOf":{"@id":"https:\/\/tutorial.eyehunts.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/iterate-over-list-of-strings-python-example-code\/#primaryimage"},"image":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/iterate-over-list-of-strings-python-example-code\/#primaryimage"},"thumbnailUrl":"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/11\/Iterate-over-list-of-strings-Python.jpg","datePublished":"2021-11-11T10:24:30+00:00","dateModified":"2023-03-17T12:42:16+00:00","author":{"@id":"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1"},"description":"Using For loop, while loop or enumerate() function can easily Iterate over a list of strings in Python. You can use list comprehension to...","breadcrumb":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/iterate-over-list-of-strings-python-example-code\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/tutorial.eyehunts.com\/python\/iterate-over-list-of-strings-python-example-code\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tutorial.eyehunts.com\/python\/iterate-over-list-of-strings-python-example-code\/#primaryimage","url":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/11\/Iterate-over-list-of-strings-Python.jpg?fit=210%2C152&ssl=1","contentUrl":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/11\/Iterate-over-list-of-strings-Python.jpg?fit=210%2C152&ssl=1","width":210,"height":152},{"@type":"BreadcrumbList","@id":"https:\/\/tutorial.eyehunts.com\/python\/iterate-over-list-of-strings-python-example-code\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/tutorial.eyehunts.com\/"},{"@type":"ListItem","position":2,"name":"Iterate over list of strings Python | Example code"}]},{"@type":"WebSite","@id":"https:\/\/tutorial.eyehunts.com\/#website","url":"https:\/\/tutorial.eyehunts.com\/","name":"Tutorial","description":"By EyeHunts","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/tutorial.eyehunts.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1","name":"Rohit","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/image\/","url":"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777374971","contentUrl":"https:\/\/tutorial.eyehunts.com\/wp-content\/litespeed\/avatar\/2b27529b86d6dfb5336897e07c93a827.jpg?ver=1777374971","caption":"Rohit"},"description":"Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology &amp; like learning technical.","url":"https:\/\/tutorial.eyehunts.com\/author\/rohit\/"}]}},"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":16395,"url":"https:\/\/tutorial.eyehunts.com\/python\/how-to-make-all-items-in-a-list-lowercase-python-example-code\/","url_meta":{"origin":18018,"position":0},"title":"How to make all items in a list lowercase Python | Example code","author":"Rohit","date":"July 13, 2021","format":false,"excerpt":"Use the string lower() method to convert every element in a list of strings into lowercase in Python. Python list variable that contains strings needed to iterate through the loop and add back lowercase value into a list. Make all items in a list lowercase example in Python Simple python\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"How to make all items in a list lowercase Python","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/07\/How-to-make-all-items-in-a-list-lowercase-Python.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":32848,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-iterating\/","url_meta":{"origin":18018,"position":1},"title":"Python Iterating","author":"Rohit","date":"August 4, 2023","format":false,"excerpt":"In Python, iterating refers to the process of looping through elements in a sequence or collection one by one. Python provides several ways to iterate over data, such as lists, tuples, dictionaries, sets, strings, and more. Here are some common methods for iterating in Python: For loop: The for loop\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2023\/08\/Python-Iterating.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2023\/08\/Python-Iterating.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2023\/08\/Python-Iterating.jpg?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":17729,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-iterate-string-example-code\/","url_meta":{"origin":18018,"position":2},"title":"Python iterate string | Example code","author":"Rohit","date":"November 3, 2021","format":false,"excerpt":"Simply use loops like (for loop & while loop) to iterate strings in Python. In this tutorial, we will find out different ways to iterate strings in Python. Python iterate string example Simple example code s = \"Hello\" for ch in s: print(ch, \"index :\", s.index(ch)) Output: Iterate String with\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Python iterate string","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/11\/Python-iterate-string.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":16454,"url":"https:\/\/tutorial.eyehunts.com\/python\/how-to-capitalize-elements-in-list-python-example-code\/","url_meta":{"origin":18018,"position":3},"title":"How to capitalize elements in list Python | Example code","author":"Rohit","date":"July 13, 2021","format":false,"excerpt":"Use string upper() method to convert every element in a list of strings into uppercase (capitalize) in Python code. Example capitalize elements in list Python Simple python example code. Using an upper() method with Loop Use a Python for loop to iterate through each item in a given list of\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"How to capitalize elements in list Python","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/07\/How-to-capitalize-elements-in-list-Python.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":18719,"url":"https:\/\/tutorial.eyehunts.com\/python\/iterate-list-of-dictionaries-python-example-code\/","url_meta":{"origin":18018,"position":4},"title":"Iterate list of dictionaries Python | Example code","author":"Rohit","date":"August 31, 2021","format":false,"excerpt":"There are many ways to Iterate the list of dictionaries in Python. Some methods are using range with len function, Using while loop, List Comprehension, etc. the possibilities are endless, it's your choice what you prefer. Examples Iterate list of dictionaries in Python Simple example code. Iterate over the indices\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Iterate list of dictionaries Python","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Iterate-list-of-dictionaries-Python.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":22087,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-iterate-list-with-index-example-code\/","url_meta":{"origin":18018,"position":5},"title":"Python iterate list with index | Example code","author":"Rohit","date":"November 11, 2021","format":false,"excerpt":"Use the built-in function enumerate() to access the index in a for loop while iterating a list in Python. for idx, val in enumerate(ints): print(idx, val) Note: Using an additional state variable, such as an index variable (which you would normally use in languages such as C or PHP), is\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Python iterate list with index","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/11\/Python-iterate-list-with-index.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/18018","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/comments?post=18018"}],"version-history":[{"count":1,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/18018\/revisions"}],"predecessor-version":[{"id":37093,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/18018\/revisions\/37093"}],"wp:attachment":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/media?parent=18018"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/categories?post=18018"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/tags?post=18018"},{"taxonomy":"post_series","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/post_series?post=18018"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}