I would like to join word from one nested list together with the word "and" in between. For example:
l1 = [Patrick, Peter, Jerome], [Lisa, Karen, Alice]
l2 should be: [Patrick and Lisa, Peter and Karen, Jerome and Alice]
The code should not make a difference whether there are 2,3 or whatever amount of lists in the nested list.
I have tried iterating over the range of lists in the variable and then append the result to a new variable. However, the outcome is just the first combination or the results end after the second combination.
def names(one):
newlist = []
x = 0
for y in range(len(one)):
newlist.append(one[x][y] + " and " + one[x+1][y])
x += 1
return newlist
['Patrick and Lisa']
is what i got untill now. I know it has something to do with the iteration but since i am pretty new to python i got stuck.