Where is 'palindrome' defined?

Grant Edwards invalid at invalid.invalid
Mon Jun 1 11:02:11 EDT 2015


On 2015-06-01, Gary Herron <gherron at digipen.edu> wrote:
> On 05/31/2015 09:46 PM, fl wrote:
>> Hi,
>>
>> When I search solution of reverse a string/number, I came across a short
>> function online:
>>
>>>>> def palindrome(num):
>> 	return str(num) == str(num)[::-1]
>>
>> I thought that it is a general function. And with the following variable:
>
> No, this  function is not built into Python because...

Because writing a palindrome predicate is something that is only ever
done as a homework exercise in an introduction to programming class.
If it were part of the standard library, Python would not be
appropriate for such a class.

-- 
Grant Edwards               grant.b.edwards        Yow! If Robert Di Niro
                                  at               assassinates Walter Slezak,
                              gmail.com            will Jodie Foster marry
                                                   Bonzo??



More information about the Python-list mailing list