Python program to concatenate two strings using recursion
Concat() is a recursive function that takes two alphabetically ordered strings and merges them.
x
9
1
def Concat(a, b):
2
if a:
3
if b:
4
if a[:1] < b[:1]:
5
return a[:1] + Concat(a[1:], b)
6
return b[:1] + Concat(a, b[1:])
7
return a
8
return b
9
print(Concat('Web','educlick'))
Output:
Webeduclick