How do you use the reverse function | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How do you use the reverse function

It's been giving me a hard time

28th Apr 2021, 11:04 AM
dalton mutugi
dalton mutugi - avatar
2 Answers
+ 1
reverse is a method of list, that works in-place, which means it modify the list directly: x = list(range(5)) print(x) x.reverse() print(x)
28th Apr 2021, 1:30 PM
Lisa
Lisa - avatar
+ 2
This is as good an explanation as anything: https://www.tutorialspoint.com/JUMP_LINK__&&__python__&&__JUMP_LINK/list_reverse.htm If you're confused by why a specific Python script involving reverse doesn't work, share that and say what you expect it to do. Then I/we can explain why it doesn't work like that. It is hard to understand your specific confusion when you aren't more specific than reverse is giving you a hard time.
28th Apr 2021, 1:34 PM
Josh Greig
Josh Greig - avatar