I have two lists of strings that, in a better world, would be one list. I need to concatenate the lists, but the last element of the first list needs to be concatenated with the first element of the second list. So these guys:
list1 = ["bob", "sal"]
list2 = ["ly", "nigel"]
needs to become
out = ["bob", "sally", "nigel"]
So this isn't hard, but I'm wondering why my one liner doesn't work?
out = (list1[-1] += list2.pop(0)) += list2
Why isn't this equivalent to
out = list1[-1]+=list2.pop(0)
out += list2
?
I have to do this a large percentage of the time through some 400K records. So if anyone has a better way to do this, then I'd be grateful!