Reverse a String without using inbuilt functions in Python
Write a python program to reverse a string without using built in functions:
# Taking input from the user
userinput=input('Enter your string: ')
n = 0
# iterating over each element in the string entered by the user
# and assigning the total length to n
for char in userinput:
n += 1
print("The length of the string is =",n)
newstring = []
i = 0
size = n
while i < size:
# Here, we are accessing the userinput string's letter by letter
# from the end and assigning it to the newstring variable
newstring += userinput[n-1]
n = n - 1
i+=1
# printing the new/reversed string
for data in newstring :
print(data,end="")
Sample output :
Enter your string: fundaofwebit
The length of the string is = 12
tibewfoadnuf