(site:stackoverflow.com) how do i reverse a list in python - Google Search

# Accessibility Links

Skip to main content Accessibility help
Accessibility feedback
Sign in

- Remove
Report inappropriate predictions
About 133,000 results (0.35 seconds)

# Search Results

## Web results

### How can I reverse a list in Python? - Stack Overflow

stackoverflow.com › ...
stackoverflow.com › ...
You can make use of the reversed function for this as: >>> array=[0,10,20,40] >>> for i in reversed(array): ... print(i). Note that reversed(...) does not return a list.
35 answers

## People also ask

How do you reverse a list in Python?
How do you reverse a list without reverse in Python?
How do you reverse a list in stackoverflow Python?
Is there a reverse function in Python?
Feedback

## Web results

### How do I reverse a part (slice) of a list in Python? - Stack ...

stackoverflow.com › questions › how-do-i-reverse-a-pa...
stackoverflow.com › questions › how-do-i-reverse-a-pa...
Nov 27, 2016 - a[2:4] creates a copy of the selected sublist, and this copy is reversed by a[2:4].reverse() . This does not change the original list. Slicing Python ...
7 answers

### Python reverse list - Stack Overflow

stackoverflow.com › questions › python-reverse-list
stackoverflow.com › questions › python-reverse-list
Sep 9, 2012 - .reverse() returns None . Therefore you should not be assigning it to a variable. Use this instead: stra = 'This is a string' revword = stra.split() ...
8 answers

### list in reverse order python - Stack Overflow

stackoverflow.com › questions › list-in-reverse-order-p...
stackoverflow.com › questions › list-in-reverse-order-p...
Feb 6, 2018 - I'd actually do something like this (I'm assuming you cant use reversed() ). This uses slicing notation to reverse a list. def reverse(s): return s[::-1].
2 answers

### Python : Reverse Order Of List - Stack Overflow

stackoverflow.com › questions › python-reverse-order-...
stackoverflow.com › questions › python-reverse-order-...
Nov 23, 2012 - lines.sort(key=itemgetter(2), reverse=True). or if you just want to reverse the list lines.reverse(). or if you want to copy the list into a new, ...
2 answers

### Reversing a list in python 3 - Stack Overflow

stackoverflow.com › questions › reversing-a-list-in-pyt...
stackoverflow.com › questions › reversing-a-list-in-pyt...
Well, your question is a little confusing to me. "Reverse" is to read a list from the ending to the beginning. That said, the reversed version of mobbed should be ...
1 answer

### Best way to create a "reversed" list in Python? - Stack Overflow

stackoverflow.com › questions › best-way-to-create-a-r...
stackoverflow.com › questions › best-way-to-create-a-r...
Sep 14, 2010 - newlist = oldlist[::-1]. The [::-1] slicing (which my wife Anna likes to call "the Martian smiley";-) means: slice the whole sequence, with a step of -1, ...
3 answers

### creating a reverse method for a python list from scratch - Stack ...

stackoverflow.com › questions › creating-a-reverse-met...
stackoverflow.com › questions › creating-a-reverse-met...
You are changing the list that you iterate on it (data_list) because of that it's not working , try like this: def reverse(data_list): length = len(data_list) s = length ...
13 answers

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

stackoverflow.com › questions › how-to-reverse-a-list-...
stackoverflow.com › questions › how-to-reverse-a-list-...
Nov 7, 2015 - In [24]: L = [[1,2,3],[4,5,6],[7,8,9]] In [25]: L[::-1] Out[25]: [[7, 8, 9], [4, 5, 6], [1, 2, 3]].
1 answer

### How do I reverse a sublist in a list in place? - Stack Overflow

stackoverflow.com › questions › how-do-i-reverse-a-su...
stackoverflow.com › questions › how-do-i-reverse-a-su...
Mar 8, 2014 - Partial reverse with no temporary list (replace range with xrange if you use Python 2): def partial_reverse(list_, from_, to): for i in range(0, int((to ...
11 answers

### Searches related to (site:stackoverflow.com) how do i reverse a list in python

reverse a list in python without reverse function

how to reverse a list in python using for loop

reverse list python slicing

reverse part of list python

how to reverse a string in list in python

python [::-1] reverse

reverse a set in python

reverse nested list python

# Footer Links

- - - Learn more
Help Send feedback Privacy Terms
Google apps