About 197,000 results
Open links in new tab
  1. python - How do I reverse a list or loop over it backwards? - Stack ...

    How do I iterate over a list in reverse in Python? See also: How can I get a reversed copy of a list (avoid a separate statement when chaining a method after .reverse)?

  2. Most efficient way to reverse a numpy array - Stack Overflow

    Jul 21, 2011 · Believe it or not, after profiling my current code, the repetitive operation of numpy array reversion ate a giant chunk of the running time. What I have right now is the common view-based …

  3. How do I reverse a part (slice) of a list in Python?

    Nit: " Slicing Python lists always creates copies "—except when they are assigned to, as in a[2:4] = reversed(a[2:4]) in the OP's example. People may be led to think that x = reversed(x) and x.reverse() …

  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 index.

  5. How do I reverse a list using recursion in Python?

    Oct 19, 2008 · I want to have a function that will return the reverse of a list that it is given -- using recursion. How can I do that?

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

    I can think of some ways to do so in python (creating a list of range(1,n+1) and reverse it, using while and --i, ...) but I wondered if there's a more elegant way to do it.

  7. python - Sort a list in reverse order - Stack Overflow

    Apr 16, 2017 · Sort a list in reverse order Asked 8 years, 8 months ago Modified 1 year, 11 months ago Viewed 72k times

  8. python - Right way to reverse a pandas DataFrame? - Stack Overflow

    This mirrors the python list reversal syntax lst[::-1] and is clear in its intent. With the loc syntax, you are also able to slice columns if required, so it is a bit more flexible. Some points to consider while …

  9. Print a list in reverse order with range ()? - Stack Overflow

    Sep 2, 2011 · Using "reversed" with python generator (assuming we ware talking of Python 3 range built-in) is just conceptually wrong and teaches wrong habits of not considering memory/processing …

  10. Reversing a list/array in Python - Stack Overflow

    Oct 31, 2020 · It really depends on what you want in your program. If you simply want to show how the reversed list looks like, use slicing or reversed (). You can of course use them like the first method - …