How to reverse a string in Lua
In Lua, there are many functions that are useful to manipulate strings. We can use the string.reverse function if we need to reverse a string.
A visual representation of string.reverse()
Syntax
string = string.reverse(string)
Parameters
The function only needs a valid string as a mandatory parameter.
Return value
The reverse function will reverse the string given as input.
Code
In this example, we will reverse the string "Hello, Educative!":
ourstring = "Hello, Educative!"print(string.reverse(ourstring))
Expected output
!evitacudE ,olleH