- To reverse a string
User Input: Hello World
Output: dlroW olleH
s1=input("Enter your string : ")
reverse = ""
l=len(s1)-1
while l!=-1 :
reverse+=s1[l]
l-=1
print("Your reversed string : ",reverse)
Enter Your string : fun with code Your reversed string : edoc htiw nufProgram
Main Logic :
# varibale 'l' holds length of string - 1 (since index starts from 0)
while l!=-1 :
reverse+=s1[l]
l-=1
Concept
Coming Soon !
QuickIn order to succeed you must fail, so that you know what not to do the next time.