Maintenance Mode

Have Patience Working on it

Merge two strings by taking characters alternatively

Given two string write a function to merge both by taking characters alternatively
s1 = "Python"

s2 = "Django"

Output = "PDyjtahnogno"

Observe it carefully program will work when the length of both strings are equal. However, it fails when two strings are of different length and gives an error.

ERROR: index out of range.
A solution to handle this situation.

s1 = "Javascript"

s2 = "NodeJS"

Output = "JNaovdaeSJcSript"



Merge two strings by taking characters alternatively Merge two strings by taking characters alternatively Reviewed by Leaf Code on August 09, 2020 Rating: 5

No comments:

SET ADT Using Students courses example

Powered by Blogger.