{"id":7876,"date":"2020-04-01T23:45:17","date_gmt":"2020-04-01T18:15:17","guid":{"rendered":"https:\/\/tutorials.eyehunts.com\/?p=7876"},"modified":"2021-05-18T19:27:26","modified_gmt":"2021-05-18T13:57:26","slug":"python-list-index-out-of-range","status":"publish","type":"post","link":"https:\/\/tutorial.eyehunts.com\/python\/python-list-index-out-of-range\/","title":{"rendered":"Python List index out of range | What does mean &#038; How to fix it?"},"content":{"rendered":"\n<p>If you try to access the&nbsp;<strong>empty or None element<\/strong>&nbsp;by pointing available index of the <a href=\"https:\/\/tutorial.eyehunts.com\/\/python\/python-lists-tutorial-example\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"list (opens in a new tab)\">list<\/a>, Then you will get the&nbsp;Python List index out of range error.<\/p>\n\n\n\n<p><strong>Simply<\/strong>: <code>Index Error: List index out of range<\/code>&nbsp;means you are trying to get an item in a list that doesn&#8217;t exist.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i1.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/04\/Python-List-index-out-of-range.png?fit=1024%2C241&amp;ssl=1\" alt=\"Python List index out of range\" class=\"wp-image-7881\" width=\"550\" height=\"129\" srcset=\"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/04\/Python-List-index-out-of-range.png?w=1316&amp;ssl=1 1316w, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/04\/Python-List-index-out-of-range.png?resize=300%2C71&amp;ssl=1 300w, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/04\/Python-List-index-out-of-range.png?resize=1024%2C241&amp;ssl=1 1024w, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/04\/Python-List-index-out-of-range.png?resize=768%2C181&amp;ssl=1 768w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/figure><\/div>\n\n\n\n<p>For Example, we have this list:<\/p>\n\n\n\n<p><code>['z','x','y']<\/code><\/p>\n\n\n\n<p>So &#8216;z&#8217; is the 0th item, &#8216;x&#8217; is the 1st, and &#8216;y&#8217; is the 2nd.<\/p>\n\n\n\n<p>You can get the value x by calling an index [1].<\/p>\n\n\n\n<p>But if we call index [4], then index error happens. Because there is no 4th item, so it errors.<\/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 List index out of range in Python<\/strong><\/h2>\n\n\n\n<p><strong>Note:&nbsp;<\/strong>The <a href=\"https:\/\/tutorial.eyehunts.com\/\/python\/python-list-index-function-element\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"list index (opens in a new tab)\">list index<\/a> starts from zero(0).<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">nums = [14, 5, 4, 5, 7, 32, 5]\n\nprint(nums[10])\n<\/pre>\n\n\n\n<p><strong>Output:<\/strong> IndexError: list index out of range<\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Q: How to fix the list index out of range in python?<\/strong><\/h3>\n\n\n\n<p><strong>Answer:<\/strong> To fix this error you have to use <a rel=\"noreferrer noopener\" aria-label=\"Python exception Handling. (opens in a new tab)\" href=\"https:\/\/tutorial.eyehunts.com\/\/python\/python-exception-handling-error-handling\/\" target=\"_blank\">Python exception Handling.<\/a> <\/p>\n\n\n\n<pre>\ntry:\n    gotdata = dlist[1]\nexcept IndexError:\n    gotdata = 'null'\n<\/pre>\n\n\n\n<p>Of course, you could also check the&nbsp;<code>len()<\/code>&nbsp;of&nbsp;<code>dlist<\/code>; but handling the exception is more intuitive.<\/p>\n\n\n\n<p>Ternary<\/p>\n\n\n\n<pre>gotdata = dlist[1] if len(dlist) > 1 else 'null'<\/pre>\n\n\n\n<p>Test the length:<\/p>\n\n\n\n<pre>\nif len(dlist) > 1:\n    newlist.append(dlist[1])\n    continue\n<\/pre>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>Python Loop: List Index Out of Range<\/strong><\/p>\n\n\n\n<p>We can fix this issue by iterating over a range of indexes instead:<\/p>\n\n\n\n<p><code>for i in range(len(a))<\/code><\/p>\n\n\n\n<p>and access the&nbsp;<code>a<\/code>&#8216;s items like that:&nbsp;<code>a[i]<\/code>. This won&#8217;t give any errors.<\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Do comment if you have any doubts and suggestions on this tutorial.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong>Note:<\/strong>&nbsp;This example (Project) is developed in&nbsp;PyCharm 2018.2 (Community Edition)<br>JRE: 1.8.0<br>JVM:&nbsp;<a href=\"https:\/\/openjdk.java.net\/\">OpenJDK<\/a>&nbsp;64-Bit Server VM by JetBrains s.r.o<br>macOS 10.13.6<br><strong>Python&nbsp;3.7<\/strong><br>All&nbsp;<strong>Python Programs<\/strong>&nbsp;are in Python 3, so it may change its different from python 2 or upgraded versions.<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>If you try to access the&nbsp;empty or None element&nbsp;by pointing available index of the list, Then you will get the&nbsp;Python List index out of range error. Simply: Index Error: List index out of range&nbsp;means you are trying to get an item in a list that doesn&#8217;t exist. For Example, we have this list: [&#8216;z&#8217;,&#8217;x&#8217;,&#8217;y&#8217;] So&hellip;&nbsp;<a href=\"https:\/\/tutorial.eyehunts.com\/python\/python-list-index-out-of-range\/\" rel=\"bookmark\">Read More &raquo;<span class=\"screen-reader-text\">Python List index out of range | What does mean &#038; How to fix it?<\/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,90],"post_series":[],"class_list":["post-7876","post","type-post","status-publish","format-standard","hentry","category-python","tag-python-list","tag-python-questions"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.1.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python List index out of range | What does mean &amp; How to fix? - EyeHunts<\/title>\n<meta name=\"description\" content=\"If you try to access the empty or None element by pointing available index of the list, Then you will get the Python List index out of range error.\" \/>\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\/python-list-index-out-of-range\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python List index out of range | What does mean &amp; How to fix? - EyeHunts\" \/>\n<meta property=\"og:description\" content=\"If you try to access the empty or None element by pointing available index of the list, Then you will get the Python List index out of range error.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/tutorial.eyehunts.com\/python\/python-list-index-out-of-range\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:published_time\" content=\"2020-04-01T18:15:17+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-05-18T13:57:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/i1.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/04\/Python-List-index-out-of-range.png?fit=1024%2C241&amp;ssl=1\" \/>\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=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-list-index-out-of-range\/\",\"url\":\"https:\/\/tutorial.eyehunts.com\/python\/python-list-index-out-of-range\/\",\"name\":\"Python List index out of range | What does mean & How to fix? - EyeHunts\",\"isPartOf\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-list-index-out-of-range\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-list-index-out-of-range\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i1.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/04\/Python-List-index-out-of-range.png?fit=1024%2C241&amp;ssl=1\",\"datePublished\":\"2020-04-01T18:15:17+00:00\",\"dateModified\":\"2021-05-18T13:57:26+00:00\",\"author\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1\"},\"description\":\"If you try to access the empty or None element by pointing available index of the list, Then you will get the Python List index out of range error.\",\"breadcrumb\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-list-index-out-of-range\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/tutorial.eyehunts.com\/python\/python-list-index-out-of-range\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-list-index-out-of-range\/#primaryimage\",\"url\":\"https:\/\/i1.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/04\/Python-List-index-out-of-range.png?fit=1024%2C241&amp;ssl=1\",\"contentUrl\":\"https:\/\/i1.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/04\/Python-List-index-out-of-range.png?fit=1024%2C241&amp;ssl=1\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/python-list-index-out-of-range\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/tutorial.eyehunts.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python List index out of range | What does mean &#038; How to fix it?\"}]},{\"@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":"Python List index out of range | What does mean & How to fix? - EyeHunts","description":"If you try to access the empty or None element by pointing available index of the list, Then you will get the Python List index out of range error.","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\/python-list-index-out-of-range\/","og_locale":"en_US","og_type":"article","og_title":"Python List index out of range | What does mean & How to fix? - EyeHunts","og_description":"If you try to access the empty or None element by pointing available index of the list, Then you will get the Python List index out of range error.","og_url":"https:\/\/tutorial.eyehunts.com\/python\/python-list-index-out-of-range\/","og_site_name":"Tutorial","article_published_time":"2020-04-01T18:15:17+00:00","article_modified_time":"2021-05-18T13:57:26+00:00","og_image":[{"url":"https:\/\/i1.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/04\/Python-List-index-out-of-range.png?fit=1024%2C241&amp;ssl=1","type":"","width":"","height":""}],"author":"Rohit","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Rohit","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/tutorial.eyehunts.com\/python\/python-list-index-out-of-range\/","url":"https:\/\/tutorial.eyehunts.com\/python\/python-list-index-out-of-range\/","name":"Python List index out of range | What does mean & How to fix? - EyeHunts","isPartOf":{"@id":"https:\/\/tutorial.eyehunts.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/python-list-index-out-of-range\/#primaryimage"},"image":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/python-list-index-out-of-range\/#primaryimage"},"thumbnailUrl":"https:\/\/i1.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/04\/Python-List-index-out-of-range.png?fit=1024%2C241&amp;ssl=1","datePublished":"2020-04-01T18:15:17+00:00","dateModified":"2021-05-18T13:57:26+00:00","author":{"@id":"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1"},"description":"If you try to access the empty or None element by pointing available index of the list, Then you will get the Python List index out of range error.","breadcrumb":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/python-list-index-out-of-range\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/tutorial.eyehunts.com\/python\/python-list-index-out-of-range\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tutorial.eyehunts.com\/python\/python-list-index-out-of-range\/#primaryimage","url":"https:\/\/i1.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/04\/Python-List-index-out-of-range.png?fit=1024%2C241&amp;ssl=1","contentUrl":"https:\/\/i1.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/04\/Python-List-index-out-of-range.png?fit=1024%2C241&amp;ssl=1"},{"@type":"BreadcrumbList","@id":"https:\/\/tutorial.eyehunts.com\/python\/python-list-index-out-of-range\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/tutorial.eyehunts.com\/"},{"@type":"ListItem","position":2,"name":"Python List index out of range | What does mean &#038; How to fix it?"}]},{"@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":33200,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-first-n-elements-of-list\/","url_meta":{"origin":7876,"position":0},"title":"Python first n elements of list","author":"Rohit","date":"September 27, 2022","format":false,"excerpt":"Use slice syntax to get the first n elements of a list in Python. Just use the slicing syntax [ ] by passing a 0:n as an argument to it. new_list = source_list[:N] Where 0 is the start index (it is included) and n is the end index (it is\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Python first n elements of list","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2022\/09\/Python-first-n-elements-of-list.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":7876,"position":1},"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":22097,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-for-loop-index-example-code\/","url_meta":{"origin":7876,"position":2},"title":"Python for loop index | Example code","author":"Rohit","date":"November 12, 2021","format":false,"excerpt":"Using the range() function or enumerate() function will allow us to iterate over a list and retrieve both the index and the value of each item in the Python list. Example get index and value using for loop in Python Simple example code loop over lists items with indexes. Using\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Python for loop index","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/11\/Python-for-loop-index.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":36249,"url":"https:\/\/tutorial.eyehunts.com\/python\/find-index-of-multiple-elements-in-list-python\/","url_meta":{"origin":7876,"position":3},"title":"Find index of multiple elements in list Python","author":"Rohit","date":"February 23, 2023","format":false,"excerpt":"To Find the index of multiple elements in the Python list creates a dictionary containing the index location of each item in the list. Then use the dictionary to look up each item's index location which is average time complexity O(1). Find the index of multiple elements in the list\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Find index of multiple elements in list Python","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2023\/02\/Find-index-of-multiple-elements-in-list-Python.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":36247,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-find-index-of-element-in-list\/","url_meta":{"origin":7876,"position":4},"title":"Python find index of element in list","author":"Rohit","date":"February 28, 2023","format":false,"excerpt":"Use the built-in index() function to find an index of an element in the list in Python. It returns a zero-based index in the list of the first item whose value is equal to x. Raises a ValueError if there is no such item. list.index(x[, start[, end]]) The optional arguments\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Python find index of element in list","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2023\/02\/Python-find-index-of-element-in-list.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":8054,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-list-pop-function-remove-element-from-list\/","url_meta":{"origin":7876,"position":5},"title":"Python list pop function | Remove element from the list","author":"Rohit","date":"April 16, 2020","format":false,"excerpt":"Python list pop function is used to removes the element at the given index from the list and it returns the removed item. So basically you can remove the element at the specified position by using the pop()\u00a0Method in Python List. Note:\u00a0Index in Python List starts from 0, not 1.\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\/2020\/04\/Python-list-pop-function-Remove-element-1.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/04\/Python-list-pop-function-Remove-element-1.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/04\/Python-list-pop-function-Remove-element-1.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/04\/Python-list-pop-function-Remove-element-1.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/04\/Python-list-pop-function-Remove-element-1.png?resize=1050%2C600&ssl=1 3x"},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/7876","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=7876"}],"version-history":[{"count":0,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/7876\/revisions"}],"wp:attachment":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/media?parent=7876"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/categories?post=7876"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/tags?post=7876"},{"taxonomy":"post_series","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/post_series?post=7876"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}