Example 1 — Show Browser History With the Newest Page First
Pages are stored in visit order; reversing the list puts the latest visit at index 0.
history = ["home", "search", "product", "cart"]
result = history.reverse()
print(result)
print(history)
print("most recent:", history[0]) How It Works
- Nothing returned.
resultholdsNone, the return value of every in-place list method exceptpop(). - Flipped in place. The same
historylist now runs from the last page visited to the first. - Index 0 is now the latest. After the flip, "cart" sits at the front.

