如何使用reduce()编写python程序来组合两个字符串的第二个字母 使用reduce()组合以下两个字符串的第二个字母。
如何使用reduce()编写python程序来组合两个字符串的第二个字母 使用reduce()组合以下两个字符串的第二个字母。,python,python-3.x,functools,Python,Python 3.x,Functools,string1=['Hello','Bye'] 输出应为'ey' O/p:-ey以下是代码: from functools import * string1 = ['Hello','Bye'] print (reduce(lambda a,b : a+b,(i[1] for i in string1))) 输出: ey ey
string1=['Hello','Bye']
输出应为'ey'
O/p:-
ey
以下是代码:
from functools import *
string1 = ['Hello','Bye']
print (reduce(lambda a,b : a+b,(i[1] for i in string1)))
输出:
ey
ey