Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #91637

Re: Where is 'palindrome' defined?

From Marko Rauhamaa <marko@pacujo.net>
Newsgroups comp.lang.python
Subject Re: Where is 'palindrome' defined?
Date 2015-06-01 12:21 +0300
Organization A noiseless patient Spider
Message-ID <87h9qraimu.fsf@elektro.pacujo.net> (permalink)
References <83a279a3-133d-4a50-9af3-054233bcc6af@googlegroups.com> <mailman.267.1433141892.5151.python-list@python.org>

Show all headers | View raw


David Palao <dpalao.python@gmail.com>:

> Because "palindrome" != "parlindrome"?
> Have you read the error message? Did you try to understand it?

When you are starting with any new thing, even the simplest problems
look baffling. Once you have achieved a few successes, such error
messages start to make sense.

>>>>> def palindrome(num):
>>         return str(num) == str(num)[::-1]

BTW, this simplistic function is not very practical for serious,
real-life palindromes. It does work for the naïve Finnish palindrome:

    saippuakauppias
    (= "a soap merchant")

However, it fails to detect:

    innostunut sonni
    (= "an enthusiastic bull")

let alone:

    Sota-apina nakataan raastimeen.
          Apelle pane emit.
      Saarnaa takanani paatos.

    (= "The war monkey will be chucked into a grater.
        Hand the pistils to father-in-law.
        Pathos does preach behind me.")


Marko

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Where is 'palindrome' defined? fl <rxjwg98@gmail.com> - 2015-05-31 21:46 -0700
  Re: Where is 'palindrome' defined? Gary Herron <gherron@digipen.edu> - 2015-05-31 23:55 -0700
    Re: Where is 'palindrome' defined? Grant Edwards <invalid@invalid.invalid> - 2015-06-01 15:02 +0000
  Re: Where is 'palindrome' defined? Larry Hudson <orgnut@yahoo.com> - 2015-05-31 23:56 -0700
  Re: Where is 'palindrome' defined? David Palao <dpalao.python@gmail.com> - 2015-06-01 08:58 +0200
    Re: Where is 'palindrome' defined? Marko Rauhamaa <marko@pacujo.net> - 2015-06-01 12:21 +0300
      Re: Where is 'palindrome' defined? David Palao <dpalao.python@gmail.com> - 2015-06-01 11:41 +0200
      Re: Where is 'palindrome' defined? John Ladasky <john_ladasky@sbcglobal.net> - 2015-06-02 14:14 -0700
        Re: Where is 'palindrome' defined? Marko Rauhamaa <marko@pacujo.net> - 2015-06-03 01:30 +0300
  Re: Where is 'palindrome' defined? Omar Abou Mrad <omar.aboumrad@gmail.com> - 2015-06-01 10:00 +0300
  Re: Where is 'palindrome' defined? Denis McMahon <denismfmcmahon@gmail.com> - 2015-06-01 15:17 +0000
  Re: Where is 'palindrome' defined? fl <rxjwg98@gmail.com> - 2015-06-01 17:55 -0700
    Re: Where is 'palindrome' defined? sohcahtoa82@gmail.com - 2015-06-01 18:07 -0700
    Re: Where is 'palindrome' defined? MRAB <python@mrabarnett.plus.com> - 2015-06-02 02:10 +0100

csiph-web