What is the simplest way to reverse a list in python without using any inbuilt function ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the simplest way to reverse a list in python without using any inbuilt function ?

We can use slicing technique to reverse a list in single step. e.g. list=[1,2,3,4,5,6,7,8,9] print(list[::-1]) It will print [9,8,7,6,5,4,3,2,1].

24th Jul 2017, 4:27 PM
Sandeep Singh
Sandeep Singh - avatar
1 Answer
+ 4
python has three ways to reverse a list list[::-1] reversed(list) list.reverse() pick one of them
24th Jul 2017, 4:33 PM
Mohamed Abdeljelil
Mohamed Abdeljelil - avatar