Combine second letters of the two strings in the following using reduce().
string1 = [‘Hello’,’Bye’]
string1 = [‘Hello’,’Bye’]
‘ey’
Here is the code for that:
from functools import *
string1 = ['Hello','Bye']
print (reduce(lambda a,b : a+b,(i[1] for i in string1)))
Output:
ey
from functools import reduce
string1 = ['Hello','Bye']
comparision = lambda x, y: x[1] + y[1]
print(reduce(comparision, string1))
O/P:- ey