Respuesta :
Answer:
#program in Python.
#function
def weave(s1,s2):
#if both are empty string
if(len(s1)==0 and len(s2)==0):
#return an empty string
return ""
#if length of both is greater than 0
elif(len(s1)>0 and len(s2)>0):
# recursive call to weave both strings
return s1[0]+s2[0]+weave(s1[1:],s2[1:])
# if character in s1 is left
elif(len(s1)>0):
#append them to new string
return s1[0]+weave(s1[1:],s2)
# if character in s2 is left
else:
##append them to new string
return s2[0] + weave(s1, s2[1:])
#read frist string
s1=input("Enter first string:")
#read second string
s2=input("Enter second string:")
#call the function
s3=weave(s1, s2)
#print new string
print("New string is:",s3)
Explanation:
Read two string from user and assign them to variables "s1" & "s2".Call the function weave()with both the strings as parameter.This function will recursively weave the characters of both the strings.If character left in any of the string then it will be added to the last of the woven string.
Output:
Enter first string:aaaa
Enter second string:bbbbbbb
New string is: ababababbbb