Let's say we've got a few lists as follows:
list1 = ['hi', 'hello', 'goodbye', 'caio', 1.0]
list2 = ['hi', 'bye', 1.0]
list3 = ['hi', 'bye', 'hello', 2.0]
I want to get it in this format:
newList1 = [['hi', 'hello'], ['hello', 'goodbye'], ['goodbye', 'caio'], ['caio', 1.0]]
newList2 = [['hi', 'bye'], ['bye', 1.0]]
newList3 = [['hi', 'bye'], ['bye', 'hello'], ['hello', 2.0]]
My current method is looping through the list based on len(), and appending [listN[i], listN[i+1], but this is running within another for loop of a huge dataset, so O(n^2) is brutal. Is there any way to increase the performance?
Thanks.