Answer to Question #339336 in Python for ram

Question #339336

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


1
Expert's answer
2022-05-10T13:22:44-0400
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)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS