Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Reverse an string Using Loop in Python

s = "SoftHunt"    # initial string
reversedString=[ ]
index = len(s)     # calculate length of string and save in index
while index > 0:
reversedString += s[ index - 1 ]   # save the value of str[index-1] in reverseString
index = index - 1   # decrement index
print(reversedString)   # reversed string
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Reverse #string #Using #Loop #Python
ADD COMMENT
Topic
Name
9+2 =