Return last item if duplicates exist
I have a “for item in collection:” loop, as classic as it could be. The collection is sorted, there are duplicates. I need to return the last item if duplicate values exist.
It took me 15 minutes to arrive at for item in reversed(collection): solution. That is some slow thinking! Just when I needed to think fast. Sigh.