Write a Python program that reverses a string without using any built-in functions. code example
Example 1: reverse string in python
'hello world'[::-1]
'dlrow olleh'
Example 2: Python reverse a string
# Library
def solution(str):
return ''.join(reversed(str))
# DIY with recursion
def solution(str):
if len(str) == 0:
return str
else:
return solution(str[1:]) + str[0]
Example 3: Reverse string in python
txt = "Hello World" [::-1]
print(txt)