About 1,060,000 results
Open links in new tab
  1. Backward iteration in Python - GeeksforGeeks

    Nov 20, 2024 · Backward iteration in Python is traversing a sequence (like list, string etc.) in reverse order, moving from the last element to the first. Python provides various methods for backward iteration, such as using negative indexing or employing built-in functions like reversed().

  2. iteration - How to loop backwards in python? - Stack Overflow

    def reverse(text): # Container for reversed string txet="" # store the length of the string to be reversed # account for indexes starting at 0 length = len(text)-1 # loop through the string in reverse and append each character # deprecate the length index while length>=0: txet += "%s"%text[length] length-=1 return txet

  3. How to Reverse a String in Python - W3Schools

    There is no built-in function to reverse a String in Python. The fastest (and easiest?) way is to use a slice that steps backwards, -1.

  4. python - How do I reverse a list or loop over it backwards?

    Oct 15, 2010 · There are three different built-in ways to reverse a list. Which method is best depends on whether you need to: From a speed perspective, it is best to use the above built-in functions to reverse a list.

  5. Python reversed() Method - GeeksforGeeks

    Mar 8, 2025 · reversed() function in Python lets us go through a sequence like a list, tuple or string in reverse order without making a new copy. Instead of storing the reversed sequence, it gives us an iterator that yields elements one by one, saving memory.

  6. Best way to loop over a python string backwards

    Aug 9, 2015 · It is not a very pythonic or even efficient way to loop over a string backwards. It does show how one could utilize range and negative step values to build a value by looping through a string and adding elements in off the end of the string to the front of the new value.

  7. Reverse Strings in Python: reversed(), Slicing, and More

    Python provides two straightforward ways to reverse strings. Since strings are sequences, they’re indexable, sliceable, and iterable. These features allow you to use slicing to directly generate a copy of a given string in reverse order.

  8. How to Loop Through a List Backwards in Python - Tutorial Kart

    To loop through a list backwards in Python, you can use methods like reversed(), slicing ([::-1]), the range() function, or the iter() function with reversed().

  9. Python String Reversal

    String reversal is a common programming task that can be approached in multiple ways in Python. This comprehensive guide will explore various methods to reverse a string, discussing their pros, cons, and performance characteristics.

  10. Iterating Backwards in Python: A Comprehensive Guide

    Apr 11, 2025 · This blog post will explore the various ways to iterate backwards in Python, covering fundamental concepts, usage methods, common practices, and best practices. Iterating backwards in Python means traversing a sequence from the last element to the first.