understand how s and s11 shorten one character and then grow one character at a time because there is no loop.

def toChars(s):
    import string
    #s = string.lower(s)
    s = s.lower()
    ans = ''
    for c in s:
        #if c in string.lowercase:
        if c in s:
            ans = ans + c
    return ans

def isPal(s):
    if len(s) <= 1:
        return True
    else:
        s11=s[1:-1]
        equation=(s[0] == s[-1])
        returnequation=equation
        returnispal=isPal(s[1:-1])
        returnboth=returnequation and returnispal
        return returnboth

def isPalindrome(s):
    """Returns True if s is a palindrome and False otherwise"""
    mychars=toChars(s)
    returnispal=isPal(mychars)
    return returnispal

print (isPalindrome('Guttag'))
print (isPalindrome('Guttug'))
print (isPalindrome('Able was I ere I saw Elba'))
print (isPalindrome('Are we not drawn onward, we few, drawn onward to new era?'))

Open in new window


I created variables so I can see changes in a debugger ide

in def is Palindrome(s)
I do not understand how s and s11 shorten one character and then grow one character at a time because there is no loop.
LVL 1
rgb192Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

aikimarkCommented:
the ispal function is being called recursively.
0
rgb192Author Commented:
line
19
26
or both

and how
0
aikimarkCommented:
isPalindrome is the initial invocation of the isPal function.  The recursion only happens once you are inside the isPal function.  So, I think the answer to your question is 19.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rgb192Author Commented:
thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Python

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.