Write a python funaction to create a new string by appending second string in the middle of first string


Topic: Write a python funaction to create a new string by appending second string in the middle of first string

Solution

def appendMiddle(s1, s2):
    middleIndex = int(len(s1) /2)
    print("Original Strings are", s1, s2)
    middleThree = s1[:middleIndex:]+ s2 +s1[middleIndex:]
    print("After appending new string in middle", middleThree)
appendMiddle("bananna", "monkey")



List all Python Programs