How to Reverse a String in Python


In this example, we will learn how to reverse a string in Python.

Source Code

my_string = 'I love Python'
my_string_reverse = my_string[::-1]
print(my_string_reverse)

Output:

nohtyP evol I
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments