How can one reverse the order of a list in Python without using a loop? There are no other constraints on the solution space.
a = ['a','b','c']
you can try
b = a[::-1]
It will reverse the list without using loop.
You can use the same trick on any sequence/container/iterable to get item reversed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With