Hackerss.com

Hackerss.com is a community of amazing hackers

Hackerss is a community for developers, data scientitst, ethical hackers, hardware enthusiasts or any person that want to learn / share their knowledge of any aspect of digital technology.

Create account Log in
hackerss
hackerss

Posted on

Reverse a string in Python

Reverse a string - Python:


def reverse(string):
    """
    Reverse a string.

    Parameters
    ----------
    string : str
        String to reverse.

    Returns
    -------
    str
        The reversed string.
    """

    #return the reversed string
    return string[::-1]

#example
result = reverse("hello")
#output
print(result)  #olleh


Enter fullscreen mode Exit fullscreen mode

Top comments (0)