...

/

Puzzle 8: Explanation

Puzzle 8: Explanation

Let’s learn how the built-in reversed and sorted functions behave in Python.

We'll cover the following...

Try it yourself

Try executing the code below to verify the result:

Press + to interact
nums = [4, 1, 3, 2]
rev = reversed(nums)
print(sorted(rev) == sorted(rev))

Explanation

The built-in reversed function returns an iterator.

Python’s ...