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
Reviewed by Leaf Code
on
August 09, 2020
Rating:
![Merge two strings by taking characters alternatively](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7WQ-Rdt4n-hGencVc1GD6obYxuQ_L3Rk-HeF_bGNMGfESgAUr-4mG5LF0JxTYbyH47B0JF457_YWa6ukRzZ9CzC-48DS7jU9jCHRYjRZ82P-ReWEgKUTI3-c5_GSO5EqtUyTVQsl76zQ/s72-w320-c-h180/Merge+characters+of+two+strings+by+taking+characters+alternatively.png)
No comments: