for loop in python reverse order code example
Example 1: python for loop backwards
for i in range(len(item)-1, -1, -1):
print(item[i])
Example 2: reverse iteration python
for i in range(10, 0, -1):
#reverses backwards from 10
Example 3: print string in reverse order uing for loop python
# reversing a sring using recursion
def reverse_recursion(s):
if len(s) == 0:
return s
else:
return reverse_recursion(s[1:]) + s[0]