Skip to content

Instantly share code, notes, and snippets.

@Cyril-Pop
Created September 5, 2020 08:27
Show Gist options
  • Save Cyril-Pop/7f74b48cd96accc7c8e929f188128f50 to your computer and use it in GitHub Desktop.
Save Cyril-Pop/7f74b48cd96accc7c8e929f188128f50 to your computer and use it in GitHub Desktop.
insertAtsequence
def seqatIndex(mainLst, lstB):
if len(lstB) > 0:
seq = lstB.pop(0)
valueToAdd = seq.pop(0)
for i , value_ in enumerate(mainLst):
if value_ == seq[0]:
mainLst.insert(i , valueToAdd)
return seqatIndex(mainLst, lstB)
else:
return mainLst
lsta = ["4MC","3MC","2MC","1MC"]
lstb = [["5MC","3MC","2MC","1MC"], ["6MC","1MC"], ["7MC","2MC","1MC"]]
newLst = seqatIndex(lsta, lstb)
print newLst
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment