{"id":21644,"date":"2021-10-27T16:01:16","date_gmt":"2021-10-27T10:31:16","guid":{"rendered":"https:\/\/tutorial.eyehunts.com\/?p=21644"},"modified":"2023-01-16T18:07:17","modified_gmt":"2023-01-16T12:37:17","slug":"how-to-reverse-a-list-in-python-example-code","status":"publish","type":"post","link":"https:\/\/tutorial.eyehunts.com\/python\/how-to-reverse-a-list-in-python-example-code\/","title":{"rendered":"How to reverse a list in Python | Example code"},"content":{"rendered":"\n<p>Simply using the reverse() method can reverse a list in Python. It&#8217;s a built-in function in Python. You can also use the <strong>slicing<\/strong> or <a href=\"https:\/\/tutorial.eyehunts.com\/python\/python-reversed-function-with-example-code\/\">reversed() function <\/a>for it.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Reversing a list in-place with the <code>list.reverse()<\/code> method<\/li>\n\n\n\n<li>Using the \u201c<code>[::-1]<\/code>\u201d list slicing to create a reversed copy<\/li>\n\n\n\n<li>Creating a reverse iterator with the <code>reversed()<\/code> built-in function<\/li>\n<\/ol>\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 reverse a list in Python<\/strong><\/h2>\n\n\n\n<p>Simple example code.<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>List reverse()<\/strong><\/p>\n\n\n\n<p>This method doesn&#8217;t return any value and updates the existing list.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>num = &#91;2, 3, 5, 7]\n\nnum.reverse()\n\nprint(num)\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=\"270\" height=\"142\" src=\"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/How-to-reverse-a-list-in-Python.jpg?resize=270%2C142&#038;ssl=1\" alt=\"How to reverse a list in Python\" class=\"wp-image-21659\"\/><\/figure><\/div>\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>Using the \u201c[::-1]\u201d Slicing Trick to Reverse a Python List<\/strong><\/p>\n\n\n\n<p>List <a href=\"https:\/\/tutorial.eyehunts.com\/python\/negative-slicing-in-python-example-code\/\">slicing <\/a>uses the \u201c<code>[]<\/code>\u201d indexing syntax with the following \u201c<code>[start:stop:step]<\/code>\u201d pattern:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>lst = &#91;1, 2, 3, 4, 5, 6]\n\nnew_lst = lst&#91;::-1]\n\nprint(new_lst)\n<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong>: [6, 5, 4, 3, 2, 1]<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>Using the reversed() built-in function.<\/strong><\/p>\n\n\n\n<p>This method returns a reverse iterator which we use to cycle through the list.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>lst = &#91;\"A\", \"B\", \"C\"]\n\nres = reversed(lst)\n\nprint(list(res))\n<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong>: [&#8216;C&#8217;, &#8216;B&#8217;, &#8216;A&#8217;]<\/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 reverse 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>Simply using the reverse() method can reverse a list in Python. It&#8217;s a built-in function in Python. You can also use the slicing or reversed() function for it. Example reverse a list in Python Simple example code. List reverse() This method doesn&#8217;t return any value and updates the existing list. Output: Using the \u201c[::-1]\u201d Slicing&hellip;&nbsp;<a href=\"https:\/\/tutorial.eyehunts.com\/python\/how-to-reverse-a-list-in-python-example-code\/\" rel=\"bookmark\">Read More &raquo;<span class=\"screen-reader-text\">How to reverse a list in 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,174],"post_series":[],"class_list":["post-21644","post","type-post","status-publish","format-standard","hentry","category-python","tag-python-list","tag-python-reverse"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.1.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to reverse a list in Python | Example code<\/title>\n<meta name=\"description\" content=\"Simply using the reverse() method can reverse a list in Python. It&#039;s a built-in function in Python. You can also use the slicing or reversed(\" \/>\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\/how-to-reverse-a-list-in-python-example-code\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to reverse a list in Python | Example code\" \/>\n<meta property=\"og:description\" content=\"Simply using the reverse() method can reverse a list in Python. It&#039;s a built-in function in Python. You can also use the slicing or reversed(\" \/>\n<meta property=\"og:url\" content=\"https:\/\/tutorial.eyehunts.com\/python\/how-to-reverse-a-list-in-python-example-code\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:published_time\" content=\"2021-10-27T10:31:16+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-01-16T12:37:17+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/How-to-reverse-a-list-in-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\/how-to-reverse-a-list-in-python-example-code\/\",\"url\":\"https:\/\/tutorial.eyehunts.com\/python\/how-to-reverse-a-list-in-python-example-code\/\",\"name\":\"How to reverse a list in Python | Example code\",\"isPartOf\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/how-to-reverse-a-list-in-python-example-code\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/how-to-reverse-a-list-in-python-example-code\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/How-to-reverse-a-list-in-Python.jpg\",\"datePublished\":\"2021-10-27T10:31:16+00:00\",\"dateModified\":\"2023-01-16T12:37:17+00:00\",\"author\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1\"},\"description\":\"Simply using the reverse() method can reverse a list in Python. It's a built-in function in Python. You can also use the slicing or reversed(\",\"breadcrumb\":{\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/how-to-reverse-a-list-in-python-example-code\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/tutorial.eyehunts.com\/python\/how-to-reverse-a-list-in-python-example-code\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/how-to-reverse-a-list-in-python-example-code\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/How-to-reverse-a-list-in-Python.jpg?fit=270%2C142&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/How-to-reverse-a-list-in-Python.jpg?fit=270%2C142&ssl=1\",\"width\":270,\"height\":142},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/tutorial.eyehunts.com\/python\/how-to-reverse-a-list-in-python-example-code\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/tutorial.eyehunts.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to reverse a list in 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":"How to reverse a list in Python | Example code","description":"Simply using the reverse() method can reverse a list in Python. It's a built-in function in Python. You can also use the slicing or reversed(","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\/how-to-reverse-a-list-in-python-example-code\/","og_locale":"en_US","og_type":"article","og_title":"How to reverse a list in Python | Example code","og_description":"Simply using the reverse() method can reverse a list in Python. It's a built-in function in Python. You can also use the slicing or reversed(","og_url":"https:\/\/tutorial.eyehunts.com\/python\/how-to-reverse-a-list-in-python-example-code\/","og_site_name":"Tutorial","article_published_time":"2021-10-27T10:31:16+00:00","article_modified_time":"2023-01-16T12:37:17+00:00","og_image":[{"url":"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/How-to-reverse-a-list-in-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\/how-to-reverse-a-list-in-python-example-code\/","url":"https:\/\/tutorial.eyehunts.com\/python\/how-to-reverse-a-list-in-python-example-code\/","name":"How to reverse a list in Python | Example code","isPartOf":{"@id":"https:\/\/tutorial.eyehunts.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/how-to-reverse-a-list-in-python-example-code\/#primaryimage"},"image":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/how-to-reverse-a-list-in-python-example-code\/#primaryimage"},"thumbnailUrl":"https:\/\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/How-to-reverse-a-list-in-Python.jpg","datePublished":"2021-10-27T10:31:16+00:00","dateModified":"2023-01-16T12:37:17+00:00","author":{"@id":"https:\/\/tutorial.eyehunts.com\/#\/schema\/person\/69ca2cb8c13fdce0ee5b39d6175119b1"},"description":"Simply using the reverse() method can reverse a list in Python. It's a built-in function in Python. You can also use the slicing or reversed(","breadcrumb":{"@id":"https:\/\/tutorial.eyehunts.com\/python\/how-to-reverse-a-list-in-python-example-code\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/tutorial.eyehunts.com\/python\/how-to-reverse-a-list-in-python-example-code\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tutorial.eyehunts.com\/python\/how-to-reverse-a-list-in-python-example-code\/#primaryimage","url":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/How-to-reverse-a-list-in-Python.jpg?fit=270%2C142&ssl=1","contentUrl":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/How-to-reverse-a-list-in-Python.jpg?fit=270%2C142&ssl=1","width":270,"height":142},{"@type":"BreadcrumbList","@id":"https:\/\/tutorial.eyehunts.com\/python\/how-to-reverse-a-list-in-python-example-code\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/tutorial.eyehunts.com\/"},{"@type":"ListItem","position":2,"name":"How to reverse a list in 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":8364,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-reverse-list-with-reverse-function-other-ways\/","url_meta":{"origin":21644,"position":0},"title":"Python reverse list | with reverse() function &#038; Other ways","author":"Rohit","date":"May 6, 2020","format":false,"excerpt":"You can reverse Python List using an inbuilt reverse() function and other ways. The python reverse() function is mainly used to reverses the elements of a given list(Array). In this tutorial, our main top will be the reverse() function. Syntax doesn't take any argument. list.reverse() Return Value It Doesn't return\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":17325,"url":"https:\/\/tutorial.eyehunts.com\/python\/reverse-indexing-in-python-example-code\/","url_meta":{"origin":21644,"position":1},"title":"Reverse indexing in Python | Example code","author":"Rohit","date":"August 25, 2021","format":false,"excerpt":"Reversing indexing of list in reverse the List in Python. It could do easily done by using Slice Notation in python. list[::-1] Example reverse indexing in Python Simple example code, Reverse a list. list1 = [1, 2, 3, 4, 5, 6, 0] reverse = list1[::-1] print(reverse) Another solution using reversed\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Reverse indexing in Python","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Reverse-indexing-in-Python.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":8367,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-reverse-string-using-loop-recursion-stack-slice-reversed\/","url_meta":{"origin":21644,"position":2},"title":"Python reverse string | Using loop, recursion, stack, slice, reversed","author":"Rohit","date":"May 23, 2020","format":false,"excerpt":"The string is a sequence of character data. There is no built-in function to reverse a string.\u00a0But you can use slice, loop, recursion, reversed, join, etc function to reverse a string in python. Way to Python reverse string Loop - for-loopsliceRecursionreversed with join()stack Example of Python reverse string We will\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\/05\/Python-reverse-string-Using-loop-recursion-stack-slice-reversed.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/05\/Python-reverse-string-Using-loop-recursion-stack-slice-reversed.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/05\/Python-reverse-string-Using-loop-recursion-stack-slice-reversed.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/05\/Python-reverse-string-Using-loop-recursion-stack-slice-reversed.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2020\/05\/Python-reverse-string-Using-loop-recursion-stack-slice-reversed.png?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":21590,"url":"https:\/\/tutorial.eyehunts.com\/python\/python-reversed-function-with-example-code\/","url_meta":{"origin":21644,"position":3},"title":"Python reversed() function with Example code","author":"Rohit","date":"October 27, 2021","format":false,"excerpt":"Python reversed() function is used to Reverse the sequence of a list or other iterator object. This function actually returns the reversed iterator of the given sequence and takes a single parameter. The syntax of reversed() is: reversed(seq) Python reversed() function examples Simple example code Reverse the sequence of a\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Python reversed function","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/10\/Python-reversed-function.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":17321,"url":"https:\/\/tutorial.eyehunts.com\/python\/reverse-for-loop-in-python-example-code\/","url_meta":{"origin":21644,"position":4},"title":"Reverse for loop in Python | Example code","author":"Rohit","date":"August 9, 2021","format":false,"excerpt":"To reverse for loop in Python just need to read the last element first and then the last but one and so on till the element is at index 0. You can do it with the range function, List Comprehension, or reversed() function. Example Reverse for loop in Python Simple\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Reverse for loop in Python","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Reverse-for-loop-in-Python.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":17323,"url":"https:\/\/tutorial.eyehunts.com\/python\/reverse-a-list-in-python-without-reverse-function-example-code\/","url_meta":{"origin":21644,"position":5},"title":"Reverse a list in Python without reverse function | Example code","author":"Rohit","date":"August 25, 2021","format":false,"excerpt":"In Python use a for loop and swap the first and last items, the second and the one before the last item, and so on until the given list is reversed. You can also use Recursion or slice notation to reverse a list. Example reverse a list in Python without\u2026","rel":"","context":"In &quot;Python&quot;","block_context":{"text":"Python","link":"https:\/\/tutorial.eyehunts.com\/category\/python\/"},"img":{"alt_text":"Reverse a list in Python without reverse function","src":"https:\/\/i0.wp.com\/tutorial.eyehunts.com\/wp-content\/uploads\/2021\/08\/Reverse-a-list-in-Python-without-reverse-function.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\/21644","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=21644"}],"version-history":[{"count":1,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/21644\/revisions"}],"predecessor-version":[{"id":35538,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/posts\/21644\/revisions\/35538"}],"wp:attachment":[{"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/media?parent=21644"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/categories?post=21644"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/tags?post=21644"},{"taxonomy":"post_series","embeddable":true,"href":"https:\/\/tutorial.eyehunts.com\/wp-json\/wp\/v2\/post_series?post=21644"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}