for c in reversed(string):
print c
string = "trick or treat"
for i in range(len(string)-1, 0-1, -1):
print string[i]
string = "trick or treat"
for c in string[::-1]:
print c
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
# reversing a sring using recursion
def reverse_recursion(s):
if len(s) == 0:
return s
else:
return reverse_recursion(s[1:]) + s[0]