1# in order to make a string reversed in python
2# you have to use the slicing as following
3
4string = "racecar"
5print(string[::-1])
6
1string = 'hello people of india'
2words = string.split() #converts string into list
3print(words[::-1])
1#linear
2
3def reverse(s):
4 str = ""
5 for i in s:
6 str = i + str
7 return str
8
9#splicing
10'hello world'[::-1]
1str1="Hello"
2#if u want to take length input from user then use the next line
3#n=int(input("enter the no of elements: ")) #this one
4
5#if u don't wanna ask user the length then directly use this next line
6n=len(str1)
7
8for i in range(-1,-(n+1),-1):
9 print(str1[i],end='')
10#prints olleh
11
1# Library
2def solution(str):
3 return ''.join(reversed(str))
4
5# DIY with recursion
6def solution(str):
7 if len(str) == 0:
8 return str
9 else:
10 return solution(str[1:]) + str[0]
11