Python program to reverse a string (Simple Ways)

Spread the love

In this you will learn, How to write python program to reverse a string.

In this first example, we will reversed function to reverse string.

Example Program 1:

string="online tutorials" print(''.join(reversed(string)))

Output:

slairotut enilno
Here we will use lists with reverse function.
Example Program 2:
string = "online tutorials" rev=list(reversed(string)) print(rev)

Output:

['s', 'l', 'a', 'i', 'r', 'o', 't', 'u', 't', ' ', 'e', 'n', 'i', 'l', 'n', 'o']
admin

admin

Leave a Reply

Your email address will not be published. Required fields are marked *