How to reverse a string in Python
To reverse a string use the slice syntax: my_string = "ferrari" my_string_reversed = my_string[::-1] print(my_string) print(my_string_reversed) ferrari irarref The slice syntax allows you to set a step, which is -1 in the example. The default step is 1, that is,…