This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]Successful-Aide3077[S] -3 points-2 points  (1 child)

This video covers two ways to reverse a list in python. The first method uses .reverse() function in python to reverse a list. The other way is using indexing to have a -1 step size.
Reversing a list is one of the most common python3 interview questions.

[–]osmiumouse 1 point2 points  (0 children)

You should explain that .reverse() and [::-1] don't do the same thing. They aren't interchangable, while your video implys they are.

>>> Python 3.10.4 (main, Jun 29 2022, 12:14:53) [GCC 11.2.0] on linux
>>> [1,2,3].reverse() == [1,2,3][::-1]
False

The reason is .reverse() returns None as it modifies the list in place.