About 51 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. Best way to create a "reversed" list in Python? - Stack Overflow

    In Python, what is the best way to create a new list whose items are the same as those of some other list, but in reverse order? (I don't want to modify the existing list in place.) Here is one so...

  3. Python reverse list - Stack Overflow

    Sep 9, 2012 · 0 List reverse can be done using more than one way. As mentioned in previous answers two are very prominent, one with reverse() function and two with slicing feature. I'm giving some …

  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 to reverse a list without modifying the original list in Python

    Jan 21, 2017 · from copy import deepcopy L = deepcopy(R) But in practise there is rarely a need to make explicit copies. Python provides e.g. the reversed built-in that can be used to iterate through …

  6. python - How do I reverse a sublist in a list in place ... - Stack Overflow

    I'm supposed to create a function, which input is a list and two numbers, the function reverses the sublist which its place is indicated by the two numbers. for example this is what it's supposed t...

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

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

  8. How to reverse a list of lists in python? - Stack Overflow

    Nov 7, 2015 · Note for the record: reversed is lazily returning the reversed elements of the outer list; you need to iterate the value it returns, or wrap in a list constructor to convert it to a new list. Alternatively, …

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

  10. 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 …