.reverse()
Published Sep 8, 2023
Contribute to Docs
The .reverse()
function takes a valid string and rearranges it in reverse order.
Syntax
string.reverse(originalString)
The originalString
is the string to be reversed.
Example
The code below demonstrates a basic implementation of the .reverse()
method:
originalString = "Hello, World!"newString = string.reverse(originalString)print(newString)
This will return the following output:
!dlroW ,olleH
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.