Python. Create string date getting items at indexes of sublists and replace date by the indexes

This line creates the new sublist with items first and date. In my example, list was a single item so the structure remained “flattened”. This is no longer the case.

These lines loop through the items in last and append each item to our sublist, making sure we don’t have a sublist within a sublist, i.e. keeping everything flattened.

Because first is now a sublist of items 0-6, you’ll have to do the same thing you did with last to add each item individually. You just need another loop adding the items in first to vv one at a time as well.