Created
September 5, 2020 08:27
-
-
Save Cyril-Pop/7f74b48cd96accc7c8e929f188128f50 to your computer and use it in GitHub Desktop.
insertAtsequence
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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