DigitalOcean
digitalocean.com โบ community โบ tutorials โบ python-reverse-string
Python Reverse String - 5 Ways and the Best One | DigitalOcean
August 3, 2022 - I understand the first one is to tell Python to look at all the elements in string, the second one Iโm unsure about but [ -1] means that the first item to return needs to be at length [-1]. What does the second colon operator tell Python to do? Thanks ... Hi, Thank you for the explanation. I also wanted to know how to add new lines to the output. For example I have made a reverse string input program: def reverse_slice(s): return s[::-1] s=input('enter a string ') print(s[::-1]) How would I a make my answer be on multiple lines?
Tutorialspoint
tutorialspoint.com โบ python โบ python_reversed_function.htm
Python reversed() Function
The Python reversed() function returns an iterator object which allows us to access the specified sequence in reverse order. This function is commonly used in the situation where we want to iterate over the elements of a sequence in reverse, without
Method for reversing strings - Ideas - Discussions on Python.org
There may be other methods like splitting the string, reversing the resulting list, and then joining it back, but thatโs a bit of work! There have been several times in my QA career where I am scripting in Python and need to reverse a string, but I have to look up the [::-1] syntax because ... More on discuss.python.org
In python, is it recommended to use [::-1] or reversed() to reverse a collection?
I wouldn't bother with performance. You are after all dealing with Python, probably one of the slowest popular language. Won't matter too much.
reversed() is clearer, but iirc [::-1] is more Pythonic.
More on reddit.comReversing lists in Python
[...] is technically an operator, not a function.
Why do you exclude one-element lists? Single-digit numbers are palindromes. Arguably empty lists also read the same backwards and forwards. Does the assignment tell you to exclude them?
Why do you think that palindromes can't have an even number of characters? What about
ABBAand123321?Why are you wrapping
leninint? What type do you expectlento return?
Is it just me, or is string reversing difficult/surprising?
The official Python community for Reddit! Stay up to date with the latest news, packages, and meta information relating to the Python programming language. --- If you have questions or are new to Python use r/LearnPython ... Yes, I realize that there are alternatives, but they are non-obvious (or at least not as obvious as str.reverse... More on reddit.com
Videos
02:57
Using reversed to loop in reverse in Python - YouTube
05:49
What "reversed()" ACTUALLY Does In Python - YouTube
02:24
How do you reverse a given string using Python? | Ashok ...
04:20
Python Interview Prep | Alternate Ways to Reverse a String using ...
05:16
How To Reverse A List In Python - YouTube
02:45
Python's reverse() Vs reversed() | 2MinutesPy - YouTube
W3Schools
w3schools.com โบ python โบ ref_func_reversed.asp
Python reversed() Function
Python Examples Python Compiler ... Q&A Python Bootcamp Python Certificate Python Training ... The reversed() function returns a reversed iterator object....
Bhrighu
bhrighu.in โบ blog โบ reverse-a-string-in-python
How to Reverse a String in Python (5 Easy Methods)
However, this one-liner is unparalleled in its clarity and speed for reversing. Python offers the built-in reversed() function, which returns an iterator that accesses the given sequence in the reverse order.
Python
docs.python.org โบ 3 โบ library โบ itertools.html
itertools โ Functions creating iterators for efficient looping
1 month ago - def combinations_with_replacement(iterable, r): # combinations_with_replacement('ABC', 2) โ AA AB AC BB BC CC pool = tuple(iterable) n = len(pool) if not n and r: return indices = [0] * r yield tuple(pool[i] for i in indices) while True: for i in reversed(range(r)): if indices[i] != n - 1: break else: return indices[i:] = [indices[i] + 1] * (r - i) yield tuple(pool[i] for i in indices)
Programiz
programiz.com โบ python-programming โบ methods โบ list โบ reverse
Python List reverse()
Become a certified Python programmer. Try Programiz PRO! ... The reverse() method reverses the elements of the list.
GeeksforGeeks
geeksforgeeks.org โบ python โบ reverse-string-python-5-different-ways
How to reverse a String in Python - GeeksforGeeks
We can reverse the string by taking a step value of -1. ... Python provides a built-in function called reversed() which can be used to reverse the characters in a string.
Published ย 3 weeks ago
GeeksforGeeks
geeksforgeeks.org โบ python โบ python-reversed-function
Python reversed() Method - GeeksforGeeks
February 17, 2026 - reversed() function in Python returns an iterator that accesses elements in reverse order. It does not create a new reversed copy of the sequence, making it memory-efficient.
Skillfountain
skillfountain.in โบ notes โบ reverse-function-in-python
`reversed()` Function in Python [ English ] | Skill Fountain
The reversed() function in Python is a built-in function used to return an iterator that accesses the elements of a sequence in reverse order.
Programiz
programiz.com โบ python-programming โบ methods โบ built-in โบ reversed
Python reversed()
Become a certified Python programmer. Try Programiz PRO! ... The reversed() function returns an iterator object that provides access to the elements of an iterable (list, tuple, string, etc.) in reverse order.