Click here to Skip to main content
15,851,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
# totalIndexSeq = ['0+234+6+', '++++++', '012++5678']

def longestSeqFinder(totalIndexSeq):
    positionCounter = 0
    positionChecker = 0
    tryList = []
    longestSeqList = []

    for y in totalIndexSeq:

        temp = y.split("+")
        tryList.append(temp)

    for i in tryList:
        longestSeq = (max(i, key = len))
        longestSeqList.append(longestSeq)


What I have tried:

I am new to coding, and I'm honestly not sure where to begin.
Posted
Updated 22-Apr-19 12:38pm
Comments
CPallini 20-Apr-19 15:21pm    
I see no use for recursion in such a function. I mean iteration is fine there.
Richard MacCutchan 21-Apr-19 4:53am    
Since you are new I would suggest you forget about recursion until you have more experience, and can understand when it may be useful. In the above case recursion is unlikely to help you.

1 solution

Recursion means the function calls itself. If your function calls itself, it's using recursion. An obvious use for recursion would be to navigate a tree, the method always goes through the children of a node, and calls itself. When the tree ends, the recursion ends.

I've had interview questions that ask me to write a recursive function where it makes no sense. Recursion is not a complex thing, there's tons of tutorials and examples. If you want to learn recursion, I'd suggest the starting point is using an example where it makes sense to use it
 
Share this answer
 
Comments
Maciej Los 24-Apr-19 5:16am    
5ed!

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