reverse a string in python without using inbuilt function code example

Example 1: python reverse string

'String'[::-1] #-> 'gnirtS'

Example 2: reverse string in python

'hello world'[::-1]
'dlrow olleh'

Example 3: python string reverse

'hello world'[::-1]
#  'dlrow olleh'

Example 4: python reverse a string

#linear

def reverse(s): 
  str = "" 
  for i in s: 
    str = i + str
  return str

#splicing
'hello world'[::-1]

Example 5: reverse string python recursion

def reverse(string):
    if len(string) == 0:
        return string
    else:
        return reverse(string[1:]) + string[0]
a = str(input("Enter the string to be reversed: "))
print(reverse(a))