Tags
python
Asked 3 years ago
6 Aug 2021
Views 387
Palma

Palma posted

How can I reverse a range of list in python?


range(1,10)

it generate list like

[1, 2, 3, 4, 5, 6, 7, 8, 9]


i want to list the range in the reverse manner

How can I reverse a range of list in python?
python

python
answered Aug 8 '21 00:00


1. lets create first list 1 to 10

v=list(range(1,10))


2. Lets reverse it with reversed() function

print(list(reversed(v)))


its done !!

final code is

v=range(1,10)
v=list(v)
print(list(reversed(v)))
Post Answer