Ask Question

Write a recursive method to reverse a string. explain why you would not normally use recursion to solve this problem

+3
Answers (1)
  1. 8 January, 16:19
    0
    Here's a Python program:

    #!/usr/bin/python

    import sys

    def isPalindrome (string):

    if (len (string) < 2):

    return True

    elif (string[ 0 ] = = string [ - 1 ]):

    return (isPalindrome (string[ 1: - 1 ]))

    else:

    return False

    if (__name__ = = "__main__"):

    print isPalindrome (sys. argv[ 1 ])
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write a recursive method to reverse a string. explain why you would not normally use recursion to solve this problem ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers