-1

Combine second letters of the two strings in the following using reduce().

string1 = [‘Hello’,’Bye’]

output should be ‘ey’

Cprk Praveen
  • 129
  • 1
  • 10

2 Answers2

1

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
Osadhi Virochana
  • 1,294
  • 2
  • 11
  • 21
0
from functools import reduce

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

O/P:- ey

Cprk Praveen
  • 129
  • 1
  • 10