One possible reason I can think of - <br>
"- exiting this loop means all compared chars were identical hence it<br>
is a palindrome and i return True"<br><br>is probably incorrect reasoning. Think again.<br><br>Also, you may consider posting your code in a way that preserves the whitespace characters.<br><br>Cheers,<br>Xav<br><br>

<div class="gmail_quote">On 27 August 2010 18:53, Baba <span dir="ltr"><<a href="mailto:raoulbia@gmail.com">raoulbia@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

level: beginner<br>
<br>
the following code looks ok to me but it doesn't work. I would like<br>
some hints as to where my reasoning / thought goes wrong<br>
<br>
def i_palindrome(pal):<br>
 while len(pal)>1:<br>
  if pal[0] == pal[-1]:<br>
   pal=pal[1:-1]<br>
 return True<br>
<br>
print i_palindrome('annab')<br>
<br>
<br>
my reasoning:<br>
- i check the length of the string: if > 1 continue<br>
- i check first and last char: if they are equal continue<br>
- create a new, shorter string starting at index 1 and ending at<br>
second last index (up to but not including index-1<br>
-restart the while loop as long as length of string is > 1<br>
- exiting this loop means all compared chars were identical hence it<br>
is a palindrome and i return True<br>
<br>
tnx<br>
Baba<br>
<font color="#888888">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></blockquote></div><br>