[Tutor] Finding palindromes in a list
Marc Tompkins
marc.tompkins at gmail.com
Sat Jun 9 03:01:22 CEST 2012
On Fri, Jun 8, 2012 at 5:10 PM, Mike Nickey <mnickey at gmail.com> wrote:
> def compareElements(wordList):
> for item in wordList():
> if item == item.reversed():
> print item
> else:
> next(item)
>
>
reversed() is not a string method. To reverse a string, try something like
this:
> if item == item[::-1]
>
http://stackoverflow.com/questions/931092/reverse-a-string-in-python
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120608/fb9f1c20/attachment.html>
More information about the Tutor
mailing list