Click here to Skip to main content
15,881,173 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
# evenList = ['GAAGCTCG', 'AAATTT', 'CTCTAGGAC']
# oddList = ['CCTCGGGA', 'GGGCCC', 'GAGTACCTG']

def matchList(evenList, oddList, integ):
    indexElement = 0
    indexList = 0
    totalIndexSeq = []
    acceptableList = ['AT', 'TA', 'at', 'ta', 'GC', 'CG', 'gc', 'cg']

    for x in evenList:
        indexedSeq = ''

        for y in x:
            if y + oddList[indexList][indexElement] in acceptableList:
                indexedSeq += str(indexElement)
            else:
                indexedSeq += "+"
            indexElement += 1

        indexList += 1
        indexElement -= indexElement
        totalIndexSeq.append(indexedSeq)
    return totalIndexSeq
# This is what is returned:
# ['0+234+6+']
# ['0+234+6+', '++++++']
# ['0+234+6+', '++++++', '012++5678']


What I have tried:

I'm new to coding and just now learning recursion. Any tips and/or advice would be appreciated.
Posted
Updated 20-Apr-19 15:58pm
Comments
Richard MacCutchan 21-Apr-19 4:55am    
Same comment as in your other question. Recursion is not a universal solution to every problem.

1 solution

Quote:
I'm new to coding and just now learning recursion.

First of all, you need to learn what is recursive, how to recognize a recursive problem/algorithm. When a problem os not recursive by nature, it is a no go.
"Recursion occurs when a thing is defined in terms of itself or of its type."
Recursion - Wikipedia[^]
Quote:
How do I perform this function recursively?

Not all problems are defined in terms of recursive, and I don't see anything recursive in this code.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900