<jupyter_start><jupyter_text>Reverse a StringThis interview question requires you to reverse a string using recursion. Make sure to think of the base case here.Again, make sure you use *recursion* to accomplish this. **Do not slice (e.g. string[::-1]) or use iteration, there must be a recursive call for the function.**____ Fill out your solution below<jupyter_code>def reverse(s):
    if not s:
        return ''
    if len(s) <= 1:
        return s
    else:
        return s[-1] + reverse(s[:-1])
reverse('hello world')<jupyter_output><empty_output><jupyter_text>Test Your SolutionRun the cell below to test your solution against the following cases:    string = 'hello'    string = 'hello world'    string = '123456789'<jupyter_code>'''
RUN THIS CELL TO TEST YOUR FUNCTION AGAINST SOME TEST CASES
'''

from nose.tools import assert_equal

class TestReverse(object):
    
    def test_rev(self,solution):
        assert_equal(solution('hello'),'olleh')
        assert_equal(solution('hello world'),'dlrow olleh')
        assert_equal(solution('123456789'),'987654321')
        
        print ('PASSED ALL TEST CASES!')
        
# Run Tests
test = TestReverse()
test.test_rev(reverse)<jupyter_output>PASSED ALL TEST CASES!
{'fraction_non_alphanumeric': 0.1036734693877551, 'fraction_numerical': 0.025306122448979593, 'mean_word_length': 3.8844621513944224, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '354638', 'license': 'MIT', 'n_tokens_mistral': 406, 'n_tokens_neox': 365, 'n_words': 125, 'path': 'Recursion Interview Problems/Recursion Problem 1 - Reverse String .ipynb', 'repo_name': 'adityashetty0302/datastructures-and-algorithms-python', 'size': '1225'}