0

I need to create a function that reverses a string.

Name your function reverse. Call your function with the input string 'This is my string'. and assign the result to the variable my_string. Print out my_string!

  • 3
    Does this answer your question? [Reverse a string in Python](https://stackoverflow.com/questions/931092/reverse-a-string-in-python) – Ghoti Jul 23 '21 at 03:43

1 Answers1

1

You can do like this:

def string_reverse(string_value):
    return string_value[::-1]

my_string = "This is my string"
print(string_reverse(my_string))

or you can simply do it this way:

my_string = "This is my string"
print(my_string[::-1])