[Tutor] Finding palindromes in a list
Dave Angel
d at davea.name
Sat Jun 9 03:38:32 CEST 2012
On 06/08/2012 09:01 PM, Marc Tompkins wrote:
> 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]
>>
>
Also next(item) is useless and probably an error. You do not need an
else clause there. the for loop takes care of those details.
--
DaveA
More information about the Tutor
mailing list