On 8/27/2010 4:53 AM, Baba wrote:
level: beginnerthe following code looks ok to me but it doesn't work. I would like some hints as to where my reasoning / thought goes wrong def i_palindrome(pal): while len(pal)>1: if pal[0] == pal[-1]: pal=pal[1:-1] return True print i_palindrome('annab')
General practical debugging procedurewhen logic inspection fails: insert print statements at key points.
In the case above, put "print pal" before the if statement and you should see the problem. And/or "print 'equal'" after the if.
-- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
