{"id":7847,"date":"2025-04-23T07:16:42","date_gmt":"2025-04-23T07:16:42","guid":{"rendered":"https:\/\/ubiq.co\/tech-blog\/?p=7847"},"modified":"2025-05-23T07:21:58","modified_gmt":"2025-05-23T07:21:58","slug":"how-to-reverse-string-in-python","status":"publish","type":"post","link":"https:\/\/ubiq.co\/tech-blog\/how-to-reverse-string-in-python\/","title":{"rendered":"How to Reverse String in Python"},"content":{"rendered":"\n<p>Often Python developers are required to demonstrate how to reverse string in Python. This is a common interview question in software development and IT companies. There are several ways to reverse string in Python. In this article, we will learn how to do this.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-reverse-string-in-python\/#Why_Reverse_String_in_Python\" >Why Reverse String in Python<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-reverse-string-in-python\/#How_to_Reverse_String_in_Python\" >How to Reverse String in Python<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-reverse-string-in-python\/#1_Using_Slicing\" >1. Using Slicing<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-reverse-string-in-python\/#2_Using_reversed\" >2. Using reversed()<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-reverse-string-in-python\/#3_Using_Loops\" >3. Using Loops<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-reverse-string-in-python\/#4_Using_List_Comprehension\" >4. Using List Comprehension<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-reverse-string-in-python\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Why_Reverse_String_in_Python\"><\/span>Why Reverse String in Python<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>You might be wondering why someone would need to reverse a string in Python. There are several use cases for this problem. First of all, it is used to check if a string is a palindrome or not. A palindrome is a string that remains the same even when the sequence of its characters is reversed. Next, it is used to decrypt\/encrypt data that might have been stored or transmitted in reverse order. You can also use it to manipulate texts and data. For example, it can be a part of a bigger algorithm such as the need to create a mirror image of text in an image. As you can see, there are plenty of useful applications of string reversal so it is good to know how to do it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"How_to_Reverse_String_in_Python\"><\/span>How to Reverse String in Python<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Here are the different ways to reverse string in Python.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_Using_Slicing\"><\/span>1. Using Slicing<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>One of the most common and fastest ways to do string reversal is to use slicing. <a href=\"https:\/\/ubiq.co\/tech-blog\/how-slicing-in-python-works\/\">Slicing<\/a> is generally used to extract a substring or a range of characters from a string, list or tuple. However, it can also be used to reverse a string. Here is its syntax.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">string[start:end:step]<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>start &#8211; index to begin slicing. It is included in the slice. It is optional and defaults to 0.<\/li>\n\n\n\n<li>end &#8211; index to end slicing. It is excluded from the slice. It is optional and defaults to the string length.<\/li>\n\n\n\n<li>step &#8211; increment between indices in the slice. It is also optional and defaults to 1. A negative step value will reverse the slice.<\/li>\n<\/ul>\n\n\n\n<p>Using this method, we can reverse string with the following command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">string[::-1]<\/pre>\n\n\n\n<p>In the above command, we have kept the start index and end index empty. So it will use the entire string. We have used -1 value so that the string is traversed in reverse from the end to the start. The result is reversed string. Here is an example to demonstrate it.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">data = 'hello world'<br>print(data[::-1]) # dlrow olleh<br>print(data)       # hello world<\/pre>\n\n\n\n<p>Please note, in the above example, the original string <em>data<\/em> remains unchanged, since Python strings are immutable. So if you want to modify the original string, you need to re-assign the result of slicing back to the string variable data.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">data = 'hello world'<br>data=data[::-1]<br>print(data) # dlrow olleh<\/pre>\n\n\n\n<p>Alternatively, you can save the result of slicing as another string variable<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2_Using_reversed\"><\/span>2. Using reversed()<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>If you want to reverse a large body of text then using the above method may consume a lot of space. In such cases, you can use reversed() function that basically returns an iterator to the string characters in reverse order. This iterator does not occupy much memory and is fast. You can generate the actual reversed string by calling join() function on this iterator.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">data = 'hello world'<br>print(''.join(reversed(data))) # dlrow olleh<br>print(data)                    # hello world<\/pre>\n\n\n\n<p>In the above code, we use join() function along with empty string &#8221; so that all characters returned from reversed() function are concatenated to form a single string.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3_Using_Loops\"><\/span>3. Using Loops<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>If you want to have more control over string reversal process, then you can use a for loop for this purpose. In this case, we create an empty string to store reversed string. Then we simply loop through the string and prepend each character to the reversed string.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">data = 'hello world'<br>data2= ''<br>for i in data:<br>    data2=i+data2<br>    <br>print(data2) # dlrow olleh<\/pre>\n\n\n\n<p>This approach allows you to customize the string reversal as per your requirements. Here is an example where we exclude character &#8216;e&#8217; from reversed string.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">data = 'hello world'<br>data2= ''<br>for i in data:<br>    if i!='e':<br>        data2=i+data2<br>    <br>print(data2) # dlrow ollh<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"4_Using_List_Comprehension\"><\/span>4. Using List Comprehension<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>If you are an advanced Python programmer, and want a concise piece of code that also gives you good control over string reversal, then you can use list comprehension along with join() function. You don&#8217;t need to <a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-convert-string-to-list-in-python\/\">convert string to list<\/a> but you can directly access its characters in list comprehension.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">data = 'hello world'<br>data2=''.join([data[i] for i in range(len(data) - 1, -1, -1)])<br>    <br>print(data2)  # dlrow olleh<\/pre>\n\n\n\n<p>In the above article, we use range() function to generate a range of numbers starting from len(data)-1, that is, 10, and going down to -1 (excluded), with a step of -1. It results in a range from 10 to 0. We use this range&#8217;s items as index values, to access the string characters in reverse order. In our list comprehension we loop through this range, from 10 to 0, and use these numbers as indexes to get string variables in reverse order. Since the result of list comprehension is a list, we call join() function on this list to convert it into a string.<\/p>\n\n\n\n<p><strong>Please note<\/strong>: There are also other solutions that use stack, or recursion, but we have avoided them since they are memory intensive and can cause your system to crash in case of large strings, or code bugs.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In this article, we have learnt several different ways to easily reverse a string in Python. Generally, string reversal programs are parts of larger modules and algorithms. So it is good to know how to reverse Python string. Slicing is the most convenient and easiest solution to reverse string. If you want more control over string reversal, then you can use simple for loops and customize them as per your requirement. If you need to reverse a really large text, then you can use reversed() function along with join() function, since reversed() returns a memory-efficient iterator which is also fast.<\/p>\n\n\n\n<p>Also read:<\/p>\n\n\n\n<p><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-compare-strings-in-python\/\">How to Compare Strings in Python<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/how-to-remove-characters-from-string-in-python\/\">How to Remove Characters from String in Python<\/a><br><a href=\"https:\/\/ubiq.co\/tech-blog\/what-are-f-strings-in-python-how-to-use-f-strings-in-python\/\">What Are f-strings in Python? How to Use f-strings?<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes Python developers need to reverse string in Python. Here are the different ways to do this.<\/p>\n","protected":false},"author":1,"featured_media":7858,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[301],"tags":[413],"class_list":["post-7847","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-reverse-string"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Reverse String in Python - Ubiq BI<\/title>\n<meta name=\"description\" content=\"Sometimes Python developers need to reverse string in Python. Here are the different ways to perform string reversal in Python.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ubiq.co\/tech-blog\/how-to-reverse-string-in-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Reverse String in Python - Ubiq BI\" \/>\n<meta property=\"og:description\" content=\"Sometimes Python developers need to reverse string in Python. Here are the different ways to perform string reversal in Python.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ubiq.co\/tech-blog\/how-to-reverse-string-in-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Ubiq BI\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ubiqbi\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-23T07:16:42+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-05-23T07:21:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/04\/reverse-string-in-python.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"300\" \/>\n\t<meta property=\"og:image:height\" content=\"200\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Sreeram Sreenivasan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:site\" content=\"@UbiqBI\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sreeram Sreenivasan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-reverse-string-in-python\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-reverse-string-in-python\\\/\"},\"author\":{\"name\":\"Sreeram Sreenivasan\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"headline\":\"How to Reverse String in Python\",\"datePublished\":\"2025-04-23T07:16:42+00:00\",\"dateModified\":\"2025-05-23T07:21:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-reverse-string-in-python\\\/\"},\"wordCount\":919,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-reverse-string-in-python\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/reverse-string-in-python.jpg?fit=300%2C200&ssl=1\",\"keywords\":[\"reverse string\"],\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-reverse-string-in-python\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-reverse-string-in-python\\\/\",\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-reverse-string-in-python\\\/\",\"name\":\"How to Reverse String in Python - Ubiq BI\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-reverse-string-in-python\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-reverse-string-in-python\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/reverse-string-in-python.jpg?fit=300%2C200&ssl=1\",\"datePublished\":\"2025-04-23T07:16:42+00:00\",\"dateModified\":\"2025-05-23T07:21:58+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\"},\"description\":\"Sometimes Python developers need to reverse string in Python. Here are the different ways to perform string reversal in Python.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-reverse-string-in-python\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-reverse-string-in-python\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-reverse-string-in-python\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/reverse-string-in-python.jpg?fit=300%2C200&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/ubiq.co\\\/tech-blog\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/reverse-string-in-python.jpg?fit=300%2C200&ssl=1\",\"width\":300,\"height\":200,\"caption\":\"reverse string in python\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/how-to-reverse-string-in-python\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Reverse String in Python\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#website\",\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/\",\"name\":\"Ubiq BI\",\"description\":\"Build dashboards &amp; reports in minutes\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/#\\\/schema\\\/person\\\/db98d49a766a3a111d8510935ab90abc\",\"name\":\"Sreeram Sreenivasan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g\",\"caption\":\"Sreeram Sreenivasan\"},\"description\":\"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/sreeram-sreenivasan\\\/\"],\"url\":\"https:\\\/\\\/ubiq.co\\\/tech-blog\\\/author\\\/wordpress\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Reverse String in Python - Ubiq BI","description":"Sometimes Python developers need to reverse string in Python. Here are the different ways to perform string reversal in Python.","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:\/\/ubiq.co\/tech-blog\/how-to-reverse-string-in-python\/","og_locale":"en_US","og_type":"article","og_title":"How to Reverse String in Python - Ubiq BI","og_description":"Sometimes Python developers need to reverse string in Python. Here are the different ways to perform string reversal in Python.","og_url":"https:\/\/ubiq.co\/tech-blog\/how-to-reverse-string-in-python\/","og_site_name":"Ubiq BI","article_publisher":"https:\/\/www.facebook.com\/ubiqbi","article_published_time":"2025-04-23T07:16:42+00:00","article_modified_time":"2025-05-23T07:21:58+00:00","og_image":[{"width":300,"height":200,"url":"https:\/\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/04\/reverse-string-in-python.jpg","type":"image\/jpeg"}],"author":"Sreeram Sreenivasan","twitter_card":"summary_large_image","twitter_creator":"@UbiqBI","twitter_site":"@UbiqBI","twitter_misc":{"Written by":"Sreeram Sreenivasan","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-reverse-string-in-python\/#article","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-reverse-string-in-python\/"},"author":{"name":"Sreeram Sreenivasan","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"headline":"How to Reverse String in Python","datePublished":"2025-04-23T07:16:42+00:00","dateModified":"2025-05-23T07:21:58+00:00","mainEntityOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-reverse-string-in-python\/"},"wordCount":919,"commentCount":0,"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-reverse-string-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/04\/reverse-string-in-python.jpg?fit=300%2C200&ssl=1","keywords":["reverse string"],"articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/ubiq.co\/tech-blog\/how-to-reverse-string-in-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-reverse-string-in-python\/","url":"https:\/\/ubiq.co\/tech-blog\/how-to-reverse-string-in-python\/","name":"How to Reverse String in Python - Ubiq BI","isPartOf":{"@id":"https:\/\/ubiq.co\/tech-blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-reverse-string-in-python\/#primaryimage"},"image":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-reverse-string-in-python\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/04\/reverse-string-in-python.jpg?fit=300%2C200&ssl=1","datePublished":"2025-04-23T07:16:42+00:00","dateModified":"2025-05-23T07:21:58+00:00","author":{"@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc"},"description":"Sometimes Python developers need to reverse string in Python. Here are the different ways to perform string reversal in Python.","breadcrumb":{"@id":"https:\/\/ubiq.co\/tech-blog\/how-to-reverse-string-in-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ubiq.co\/tech-blog\/how-to-reverse-string-in-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-reverse-string-in-python\/#primaryimage","url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/04\/reverse-string-in-python.jpg?fit=300%2C200&ssl=1","contentUrl":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/04\/reverse-string-in-python.jpg?fit=300%2C200&ssl=1","width":300,"height":200,"caption":"reverse string in python"},{"@type":"BreadcrumbList","@id":"https:\/\/ubiq.co\/tech-blog\/how-to-reverse-string-in-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ubiq.co\/tech-blog\/"},{"@type":"ListItem","position":2,"name":"How to Reverse String in Python"}]},{"@type":"WebSite","@id":"https:\/\/ubiq.co\/tech-blog\/#website","url":"https:\/\/ubiq.co\/tech-blog\/","name":"Ubiq BI","description":"Build dashboards &amp; reports in minutes","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ubiq.co\/tech-blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/ubiq.co\/tech-blog\/#\/schema\/person\/db98d49a766a3a111d8510935ab90abc","name":"Sreeram Sreenivasan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4b3127ed2d4bb8efb3fa0bbb52cf2efd4d0156c97fc05a503537c883e8279947?s=96&d=mm&r=g","caption":"Sreeram Sreenivasan"},"description":"Sreeram Sreenivasan is the Founder of Ubiq. He has helped many Fortune 500 companies in the areas of BI &amp; software development.","sameAs":["https:\/\/www.linkedin.com\/in\/sreeram-sreenivasan\/"],"url":"https:\/\/ubiq.co\/tech-blog\/author\/wordpress\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/ubiq.co\/tech-blog\/wp-content\/uploads\/2025\/04\/reverse-string-in-python.jpg?fit=300%2C200&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/pbGGTT-22z","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/7847","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/comments?post=7847"}],"version-history":[{"count":17,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/7847\/revisions"}],"predecessor-version":[{"id":8350,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/posts\/7847\/revisions\/8350"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media\/7858"}],"wp:attachment":[{"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/media?parent=7847"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/categories?post=7847"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubiq.co\/tech-blog\/wp-json\/wp\/v2\/tags?post=7847"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}