In: Computer Science
write both non-recursive and recursive functions that take the strings from the user and display strings in backwards in python
Thanks for the question. Below is the code you will be needing Let me know if you have any doubts or if you need anything to change. Thank You ! =========================================================================== def reverseIterative(text): for i in range(1, len(text) + 1): print(text[-i], end='') print() def reverseRecursive(text): if len(text) == 0:return else: reverseRecursive(text[1:]) print(text[0], end='') def main(): text = input('Enter a string: ') print('Printing reverse using non-recursive function') reverseIterative(text) print('Printing reverse using recursive function') reverseRecursive(text) main()
======================================================================