Method1:
abc = 'Hello World'
qwe = 'abc 123'
#intersperse words
def intersperse(abc,qwe):
list = []
for i in abc:
list.append(i)
for j in qwe:
list.append(j)
return ''.join(list)
intersperse(abc,qwe)
Output: "Habc 123eabc 123labc 123labc 123oabc 123 abc 123Wabc 123oabc 123rabc 123labc 123dabc 123"
Method 2:
#intersperse words
def intersperse(abc,qwe):
abcs = abc.split()
qwes = qwe.split()
result = sum(zip(abcs, qwes+[0]), ())[:-1]
return ''.join(result)
intersperse(abc,qwe)
Output: "HelloabcWorld" (<--somehow the 123 is missing)
Tried both methods but couldn't get it to work. I want the output to also take into consideration the blanks in between the characters as well.
Desired output: "Haeblcl o1 2W3orld"