Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (50.2k points)
Can anyone tell me how to reverse a list in Python?

1 Answer

0 votes
by (108k points)

In Python, there are two ways of reversing a list. The first method is using a built-in function, reverse(). Refer to the below code:

lst = [10, 11, 12, 13, 14, 15]

lst.reverse() 

Lst

The second way is also a built-in function, reversed(). Refer to the below code:

def Reverse(lst): 

    return [ele for ele in reversed(lst)] 

lst = [1,3,7,5,9,40,34] 

print(Reverse(lst))

If you are looking for an online course to learn Python, I recommend this Python Course by Intellipaat.

Related questions

0 votes
1 answer
asked Oct 30, 2020 in Python by Sudhir_1997 (55.6k points)
0 votes
1 answer
asked Oct 14, 2019 in Python by Sammy (47.6k points)
0 votes
1 answer
asked Jul 3, 2019 in Python by Sammy (47.6k points)
0 votes
1 answer
asked Jul 2, 2019 in Python by Anurag (33.1k points)
0 votes
1 answer
asked Jul 18, 2019 in Python by Sammy (47.6k points)

Browse Categories

...