如何编写 python 程序以使用 reduce() 合并两个字符串的第二个字母

How to write python program to Combine second letters of the two strings using reduce()

使用reduce()合并下面两个字符串的第二个字母。

string1 = [‘Hello’,’Bye’]

输出应该是‘ey’

from functools import reduce

string1 = ['Hello','Bye']
comparision = lambda x, y: x[1] + y[1]
print(reduce(comparision, string1))

O/P:- ey

这是相关代码:

from functools import *

string1 = ['Hello','Bye']
print (reduce(lambda a,b : a+b,(i[1] for i in string1)))

输出:

ey