Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.067 X-Spam-Evidence: '*H*': 0.87; '*S*': 0.00; 'python,': 0.02; "subject:' ": 0.07; 'defined,': 0.09; 'nameerror:': 0.09; 'python': 0.11; 'def': 0.14; 'programmers,': 0.16; 'wrote:': 0.16; 'why.': 0.18; 'thanks,': 0.19; '"",': 0.22; '(by': 0.22; 'defined': 0.23; 'header:In-Reply-To:1': 0.24; '(most': 0.24; 'header:User- Agent:1': 0.26; 'error': 0.27; 'checking': 0.27; 'define': 0.27; 'online:': 0.29; 'no,': 0.29; 'function': 0.30; "skip:' 10": 0.30; 'error.': 0.31; 'traceback': 0.33; 'word.': 0.33; 'subject:?': 0.34; 'file': 0.34; 'useful': 0.35; 'to:addr:python-list': 0.35; 'problem.': 0.35; 'but': 0.36; 'two': 0.37; 'hi,': 0.37; 'should': 0.37; 'subject:: ': 0.37; 'thought': 0.37; 'rather': 0.38; 'say': 0.38; 'pm,': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'why': 0.40; 'show': 0.62; 'charset:windows-1252': 0.65; 'reverse': 0.66; 'dr.': 0.69; 'special': 0.72; 'yourself': 0.73; 'received:204': 0.75; 'institute': 0.77; '(425)': 0.84; '895-4418': 0.84; 'digipen': 0.84; 'herron': 0.84; 'subject:Where': 0.84 Date: Sun, 31 May 2015 23:55:20 -0700 From: Gary Herron User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Where is 'palindrome' defined? References: <83a279a3-133d-4a50-9af3-054233bcc6af@googlegroups.com> In-Reply-To: <83a279a3-133d-4a50-9af3-054233bcc6af@googlegroups.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 50 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1433141733 news.xs4all.nl 2871 [2001:888:2000:d::a6]:48517 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:91623 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 ... Well it's hard to say why. It's not very general, or not useful to many programmers, or nobody's thought about it or made a case for including it in Python, etc. But that should be no problem. You can define it yourself (by entering the two line you have above). Then it will be defined, and calling parlindrome('...') will produce a result rather than an error. Gary Herron > >>>> a > '1234_5555' > >>>> parlindrome(a) > Traceback (most recent call last): > File "", line 1, in > parlindrome(a) > NameError: name 'parlindrome' is not defined > > > Then, I find that parlindrome is a special checking mirrored word. > I use Python 2.7.9. Why does the error message show > > name 'parlindrome' is not defined > > > > Thanks, -- Dr. Gary Herron Department of Computer Science DigiPen Institute of Technology (425) 895-4418