Question: Write a recursive function recStr () that takes two strings s1 and s2 as parameters and returns a string that consists of the two strings

Write a recursive function recStr() that takes two strings s1 and s2 as parameters and returns a string that consists of the two strings mixed together. The string returned by the function should the first character of s1 followed by the second character of s1 followed by the third character of s1 and so on. After all the characters of s1, the characters of s2 should appear in reversed order, that is, the last character of s2, followed by the second-to-the-last character of s2, etc. If either string is empty, the function returns the non-empty string. The only string functions you are allowed to use are len(), concatention, indexing (s[i] for an integer i), or slicing (s[i:j] for integers i and j). In particular you aren't allowed to reverse a string, so don't use slicing with three parts to it (e.g. s[i:j:n] for any value of n). The following shows several sample runs of the function:

Python 3.7.0 Shell File Edit She Debug Options Window Help >>>S -recStr ('123 "abc') 123cba' >>> s-recStr ( %@ ! , 'ABC. ) %@ ! CBA' 123ba' >>>S-recSt ABC','') ABC >>S -recStr (''ABC') ABC Ln: 119 Col: 4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!