This is a good thing to try in prep for an interview or just general skills in python. Even if you are not asked in an interview to do this, it is still a good skill to know how to do it.
Let’s start by defining our function.
By defining a function for this, we can create a system that will more easily reverse any string. Creating a function is also more code friendly because it is more general.
Using the brackets and double parentheses we are able to reverse the string.
Every function needs a return statement to print the answer. We want the reversal variable returned. Now let’s try it out!
It works! Let’s try another example.