reversed() in Python - what supports it and what doesn'tThe function
reversed() is built-in in Python, but it doesn't work with all data types✓ Lists - it works
reversed([1, 2, 3]) returns an iteratorlist(reversed([1, 2, 3])) → [3, 2, 1]✓ Tuples - it also works
reversed((1, 2, 3)) can be easily iterated✗ Sets - not supported
reversed({1, 2, 3}) → TypeErrorWhy? Sets don't have a fixed order, so they can't be "reversed"
If you need to reverse a set:
list(reversed(list({1, 2, 3})))
