In some programming languages, the last expression in a function is implicitly the value it returns. But in python, you have to have a return statement, or you get None.

def reverse_seq(n):
    return sorted([i for i in range(1, n+1)], reverse=True)
Answer from kojiro on Stack Overflow
๐ŸŒ
ZetCode
zetcode.com โ€บ python โ€บ reverse
Python reverse - reversing Python sequences
When we reverse items, we change their order. Note that reversing should not be confused with sorting in descending order. A Python list has a reverse function. The [::-1] slice operation to reverse a Python sequence. The reversed built-in function returns a reverse iterator.
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ methods โ€บ built-in โ€บ reversed
Python reversed()
string = 'Python' result = reversed(string) # convert the iterator to list and print it print(list(result)) # Output: ['n', 'o', 'h', 't', 'y', 'P'] ... The reversed() function takes a single argument. iterable - an iterable such as list, tuple, string, dictionary, etc.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-reversed-function
Python reversed() Method - GeeksforGeeks
February 17, 2026 - Explanation: reversed(a) returns an iterator, list() converts the iterator into a list and the elements appear in reverse order. ... Parameters: sequence - An iterable object such as list, tuple, string or range.
๐ŸŒ
Real Python
realpython.com โ€บ ref โ€บ builtin-functions โ€บ reversed
reversed() | Pythonโ€™s Built-in Functions โ€“ Real Python
The built-in reversed() function takes a sequence as an argument and returns an iterator that yields the elements in reverse order.
๐ŸŒ
Vultr Docs
docs.vultr.com โ€บ python โ€บ built-in โ€บ reversed
Python reversed() - Reverse Iterable Sequence | Vultr Docs
December 6, 2024 - The reversed() function in Python offers a simple yet powerful way to reverse sequences. It works not just with built-in types like lists, strings, and tuples but also with custom objects that implement the __iter__() and __reversed__() methods.
๐ŸŒ
Real Python
realpython.com โ€บ python-reverse-list
Reverse Python Lists: Beyond .reverse() and reversed() โ€“ Real Python
June 28, 2023 - Now, how can you reverse a list in place by hand? A common technique is to loop through the first half of it while swapping each element with its mirror counterpart on the second half of the list. Python provides zero-based positive indices to walk sequences from left to right.
๐ŸŒ
Scaler
scaler.com โ€บ home โ€บ topics โ€บ reversed in python | python reversed() function
Reversed in Python | Python reversed() Function - Scaler Topics
July 5, 2022 - The built-in reversed function in Python is used to reverse a sequence like a list, string, or tuple by creating a reverse iterator of the given sequence.
Find elsewhere
๐ŸŒ
ThePythonGuru
thepythonguru.com โ€บ python-builtin-functions โ€บ reversed
Python reversed() function - ThePythonGuru.com
January 7, 2020 - The reversed() function allows us to process the items in a sequence in reverse order. It accepts a sequence and returns an iterator.Its syntax is asโ€ฆ
๐ŸŒ
LabEx
labex.io โ€บ tutorials โ€บ python-how-to-use-built-in-functions-to-reverse-python-sequences-398260
How to use built-in functions to reverse Python sequences | LabEx
Python's versatile built-in functions offer a powerful way to reverse various sequences, including lists, tuples, and strings.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-reverse-sequence-of-strictly-increasing-integers-in-a-list
Reverse sequence of strictly increasing integers in a list-Python - GeeksforGeeks
July 11, 2025 - Reverse and add the remaining block to res. Recursion splits the list into smaller subsequences by comparing each element with the previous one. When a strictly decreasing integer is encountered, it reverses the accumulated subsequence and recurses on the remaining list.
๐ŸŒ
Real Python
realpython.com โ€บ reverse-string-python
Reverse Strings in Python: reversed(), Slicing, and More โ€“ Real Python
July 31, 2023 - Passing None to the first two arguments of slice() tells the function that you want to rely on its internal default behavior, which is the same as a standard slicing with no values for start and stop. In other words, passing None to start and stop means that you want a slice from the left end to the right end of the underlying sequence. ... The second and arguably the most Pythonic approach to reversing strings is to use reversed() along with str.join().
๐ŸŒ
Medium
medium.com โ€บ beginnerpython โ€บ python-basic-built-in-reversal-operations-fb1623a2175e
Python Basic Built-in Reversal Operations | by Aditya Garg | BeginnerPython | Medium
August 3, 2025 - Integer Reversal by Repeated Division: In case of integers, repeated division can used to reverse the number ... In Python, iterable sequences can be reversed.
๐ŸŒ
dbader.org
dbader.org โ€บ blog โ€บ python-reverse-list
How to Reverse a List in Python โ€“ dbader.org
July 11, 2017 - Python lists can be reversed in-place with the list.reverse() method. This is a great option to reverse the order of a list (or any mutable sequence) in Python. It modifies the original container in-place which means no additional memory is required.
๐ŸŒ
Toppr
toppr.com โ€บ guides โ€บ python-guide โ€บ references โ€บ methods-and-functions โ€บ methods โ€บ built-in โ€บ reversed โ€บ python-reversed
Python reversed(): reversed() Parameters, Return value from reversed()
July 29, 2021 - Yes, the reversed() function allows us to reverse the order of items in a sequence. It takes a sequence as input and outputs an iterator. ... Using the split() function of the string data type in Python, separate each word in a given string.
๐ŸŒ
The Teclado Blog
blog.teclado.com โ€บ python-quick-sequence-reversal
Quick Sequence Reversal in Python - The Teclado Blog
May 16, 2026 - Using slices we can get around these limitations, reversing any sequence we like before assigning it to a new variable. If we want to use the same variable name, of course we can, since Python allows us to bind names to new objects at will. friends = ["Rolf", "John", "Mary"] friends_reversed = friends[::-1] print(friends_reversed) # ['Mary', 'John', 'Rolf'] greet = "Hello, World!" print(greet[::-1]) # "!dlroW ,olleH"
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ ref_func_reversed.asp
Python reversed() Function
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Practice Problems Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Bootcamp Python Training ยท โฎ Built-in Functions ยท Reverse the sequence of a list, and print each item: alph = ["a", "b", "c", "d"] ralph = reversed(alph) for x in ralph: print(x) Try it Yourself ยป ยท
๐ŸŒ
Note.nkmk.me
note.nkmk.me โ€บ home โ€บ python
Reverse a List, String, Tuple in Python: reverse, reversed | note.nkmk.me
August 16, 2023 - Sort a list, string, tuple in Python (sort, sorted) reverse() is a method for mutable sequence types such as lists.
๐ŸŒ
Python Morsels
pythonmorsels.com โ€บ looping-in-reverse
Looping in reverse - Python Morsels
May 27, 2025 - >>> colors = ["purple", "blue", "green", "pink", "red"] >>> for color in reversed(colors): ... print("I like", color) ... I like red I like pink I like green I like blue I like purple ยท I find reversed a lot more readable than Python's slicing syntax, but it's also more flexible. Python's slicing syntax only works on sequences, but reversed works on any reversible iterable!
๐ŸŒ
Reintech
reintech.io โ€บ blog โ€บ python-working-with-reversed-method
Python: Working with the reversed() Method | Reintech media
March 24, 2023 - The reversed() method is a built-in function in Python that returns a reverse iterator for the given sequence. This method can be used to iterate through a sequence in reverse order, which can be useful in various cases.