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
#6
This could be done by simply slicing the list.
items = [1, 5, 23, 67]
reversed_items_copy = items[::-1]
print(f'{items=}')
print(f'{reversed_items_copy=}')
Output:
items=[1, 5, 23, 67] reversed_items_copy=[67, 23, 5, 1]
rob101 likes this post
Reply


Messages In This Thread
RE: how to reverse a list and store in another list in python - by Yoriz - Aug-14-2022, 10:16 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 371 May-23-2024, 05:39 AM
Last Post: Pedroski55
Question Python - List - Int List sophi 8 2,724 Apr-21-2022, 07:55 PM
Last Post: sophi
  Reverse Function in Python Voraman 7 3,390 Feb-13-2021, 07:21 PM
Last Post: Voraman
  reverse math in python, who will find the correct answer? Kakha 11 4,566 Jan-11-2021, 11:59 AM
Last Post: Gribouillis
  question on list in Python spalisetty06 1 2,097 Jun-30-2020, 09:03 AM
Last Post: pyzyx3qwerty
  Python list exercize ESTOUR 3 2,007 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,100 May-15-2020, 04:57 PM
Last Post: snippsat
  Python Adding +1 to a list item cointained in a dict ElReyZero 1 2,126 Apr-30-2020, 05:12 AM
Last Post: deanhystad
  Check if a list exists in given list of lists Daniel94 2 2,318 Apr-07-2020, 04:54 PM
Last Post: deanhystad
  list of strings to list of float undoredo 3 2,758 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