Python Forum
how to reverse a list and store in another list in python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to reverse a list and store in another list in python
#3
reverse reverses the list in place and returns None.
x = list(range(10))
print(x.reverse())
Output:
None
To use reverse() to make a reversed copy you first need to make a copy of the list, then reverse the copy.

Read about reverse() here:
https://docs.python.org/3/tutorial/datas...e-on-lists

Or you might use the built-in slice() function.

Read about slice() here:
https://docs.python.org/3/library/functi...lice#slice
Reply


Messages In This Thread
RE: how to reverse a list and store in another list in python - by deanhystad - Jul-04-2022, 04:42 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to parse and group hierarchical list items from an unindented string in Python? ann23fr 1 569 May-23-2024, 05:39 AM
Last Post: Pedroski55
Question Python - List - Int List sophi 8 2,819 Apr-21-2022, 07:55 PM
Last Post: sophi
  Reverse Function in Python Voraman 7 3,458 Feb-13-2021, 07:21 PM
Last Post: Voraman
  reverse math in python, who will find the correct answer? Kakha 11 4,625 Jan-11-2021, 11:59 AM
Last Post: Gribouillis
  question on list in Python spalisetty06 1 2,120 Jun-30-2020, 09:03 AM
Last Post: pyzyx3qwerty
  Python list exercize ESTOUR 3 2,026 May-23-2020, 11:10 PM
Last Post: ESTOUR
  Read data from a CSV file in S3 bucket and store it in a dictionary in python Rupini 3 7,180 May-15-2020, 04:57 PM
Last Post: snippsat
  Python Adding +1 to a list item cointained in a dict ElReyZero 1 2,150 Apr-30-2020, 05:12 AM
Last Post: deanhystad
  Check if a list exists in given list of lists Daniel94 2 2,343 Apr-07-2020, 04:54 PM
Last Post: deanhystad
  list of strings to list of float undoredo 3 2,863 Feb-19-2020, 08:51 AM
Last Post: undoredo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020