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

    Nov 20, 2024 · Python provides various methods for backward iteration, such as using negative indexing or employing built-in functions like reversed(). Use reversed () method when we …

  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 …

  3. python - Loop backwards using indices - Stack Overflow

    Jan 4, 2023 · I wanted to loop through a two lists backwards at the same time so I needed the negative index. This is my solution: a= [1,3,4,5,2] for i in range(-1, -len(a), -1): print(i, a[i])

  4. loops - Traverse a list in reverse order in Python - Stack Overflow

    Feb 10, 2009 · How do I traverse a list in reverse order in Python? So I can start from collection[len(collection)-1] and end in collection[0]. I also want to be able to access the loop …

  5. Python For Loop in Backwards - Spark By Examples

    May 30, 2024 · How to print Python for loop in backwards? you can use reversed() functions to implement the loop from backward direction. Usually, Python for loop is implemented in a …

  6. Reverse for loop in Python | Example code - EyeHunts

    Aug 9, 2021 · 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 …

  7. How to Iterate Backwards in Python - Delft Stack

    Mar 11, 2025 · The reversed() function provides a straightforward way to reverse the iteration of a sequence without modifying the original object. In this example, we created a list called my_list …

  8. How to Loop Backward Iteration in Python - Delft Stack

    Mar 11, 2025 · Learn how to perform backward iteration in Python with various methods like range(), list slicing, and the reversed() function. This article provides clear examples and …

  9. 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().

  10. Best way to loop over a python string backwards

    Aug 9, 2015 · Here is a way to reverse a string without utilizing the built in features such as reversed. Negative step values traverse backwards. rev = '' for i in range(len(text), 0, -1): rev …

  11. Some results have been removed
Refresh