Code a function which takes in a string as parameter and returns the reversed (backwards) string.

 

def reverse_string(text):

    return text[::-1]

 

 

my_string = "hello world"

reversed_string = reverse_string(my_string)

print(f"The reversed string of '{my_string}' is '{reversed_string}'")

 

 

The reversed string of 'hello world' is 'dlrow olleh'

 

 

Go Back