Skip to content

Comment on Python: copying a list the right way

Comments

Something else that's interesting is reversing a list but not in place: x[::-1]

The built-in reverse() method will do it in place.

There is also the top level reversed() function that takes some sequence and returns a reversed iterator.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.