Answer:
Following are the method to the given question:
def copy(s, n):#defining a method copy that takes two parameters
if n <= 0:#definig if to compare n value is less than equal to 0
return ''#return space
else:#definig else block
return s + copy(s, n-1)#use recursive method that return value
print(copy("by",2))#calling method and print value
print(copy("ta",2))#calling method and print value
print(copy("good by ",2))#calling method and print value
Output:
byby
tata
good by good by
Explanation:
In this code, a method "copy" is declared that takes two parameters that are "s and n" inside the method a conditional statement is used which can be defined as follows.
In the if block is used "n" variable that checks n value which is less than equal to 0 if it is true it will return a space value.
In the else block it use the recursive method that returns a value which is a copy of s that is concatenated together.