Given two strings write a program to merge the given two strings by adding character in alternating order starting with the first string if a string is longer than the other append the additional character onto the end of the merged string
input : a b c
p q r
s1 = input()
s2 = input()
i = 0
res = ""
while (i < len(s1)) and (i < len(s2)):
res += s1[i] + s2[i]
i += 1
res += s1[i:] + s2[i:]
print(res)
Comments
Leave a comment