a=input("Enter some string::")
print(a[::-1])
output:
Enter some string::anil durgam
magrud lina
method 2:
using inbuilt functions
a=input("Enter some string::")
for x in reversed(a):
print(x)
output:
Enter some string::anil durgam
m
a
g
r
u
d
l
i
n
a
join method
a=input("Enter some string::")
print(''.join(reversed(a)))
output:
Enter some string::anil
lina
without new line of the reversed string
a=input("Enter some string::")
for x in reversed(a):
print(x,end='')
output:
Enter some string::anil
lina
No comments:
Post a Comment