Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Looking for some help with the below problem exercise. Looking for the results i

ID: 3874346 • Letter: L

Question

Looking for some help with the below problem exercise. Looking for the results in python 3.

Complete the mergeStrings function in your editor. It has 2 parameters: . A string, a 2. A string,b. Your function must merge strings a and b, and then return a single merged string. A merge operation on two strings is described as follows Append alternating characters from a and b, respectively, to some new string, mergedString. Once all of the characters in one of the strings have been merged, append the remaining characters in the other string to mergedString nput Format The locked stub code in your editor reads two strings, a and b, from stdin and passes them to your function. Constraints 1 s lal Ibl s 25000 Output Format Your function must return the merged string. This will be printed to stdout by the locked stub code in your editor.

Explanation / Answer

The above program is to concatinate your two input strings .

The logic is first you have to concat alternate letters of the two strings to one output string.

Secondly we have to append rest of the letters of the two input strings to another output string.

def mergeStrings(a,b):

l1=len(a)-1

count=0

mergedstring=''

mergedstring1=''

while(count<=l1):

mergedstring=mergedstring+a[count]

altcount=count+1   

if(altcount<=l1):

mergedstring1=mergedstring1+a[altcount]

count=count+2

  

l2=len(b)-1

count1=0

altcount1=0

  

while(count1<=l2):

mergedstring=mergedstring+b[count1]

altcount1=count1+1   

if(altcount1<=l2):   

mergedstring1=mergedstring1+b[altcount1]

count1=count1+2   

return mergestring+mergestring1

c = mergeStrings('guprt','dxo')

print c

Now execute your code in your python simulator.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote