Question: This is my recursive function for the above problem. Is this recursive function? If not, how can I fix it? def duplicate(word, count): str_list =

 This is my recursive function for the above problem. Is this

This is my recursive function for the above problem. Is this recursive function? If not, how can I fix it?

def duplicate(word, count): str_list = [] for s in word: c = [s]*count str_list.extend(c) return "".join(str_list) 

Part III: Duplicating Letters (2 points) Write a recursive function duplicate that takes a non-empty string and a positive integer as its arguments, and returns a new string in which each letter of the original string has been duplicated the given number of times. The examples below will help to further clarify what the function is supposed to do. Your function must be recursive and must not use any loops. Examples: Function Call Return Value duplicate abcd', 3) aaabbbcccddd duplicate Stony 1) Stony duplicate moonmoon' 2) mmoooonnmmoooonn

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!