Checking a Number for Palindromic Behavior

rurpy at rurpy at
Mon Oct 19 20:38:28 CEST 2009

On Oct 18, 11:54 pm, alex23 <wuwe... at> wrote:
> ru... at wrote:
>> One, it was suggested without any evidence the the OP was
>> "probably" asking about homework.  My observation over
>> several years is that this group has a very poor record
>> of identifying homework problems.  And if someone can
>> conclude that the OPs problem was homework with no evidence,
>> then I can conclude that it wasn't, without evidence,
>> equally validly.
> I've always seen the accusation of "homework problem" to be less about
> homework and more about an attempt to get other people to provide
> working code. In this case, the absence of evidence (ie posting what
> code has been tried) _is_ indicative of such problems.

I don't share your view.  Whether or not a question is a
homework problem, and whether or not the questioner has
provided some indication he/she has tried to solve it
before posting are orthogonal issues, and I have not
noticed any strong correlation between them in posts to
this group.

If you feel a poster is just trying to get you to do
their work for them while putting in no effort themselves,
you are perfectly free not to respond, or to ask them to
demonstrate some effort.  I said nothing opposing this.

> This isn't about being churlish, it's about not being able to identify
> the experience level at which such posters are operating, about not
> wasting time providing answers that have already been tried & rejected
> etc etc

Again, feel free to ask the OP for whatever information
*you* feel *you* need to respond effectively.

>> As for learning better by "working it out oneself", that is
>> a myth.
> MRAB broke the OP's request down into already-understood-by-the-OP
> operations; being able to extrapolate from that is _essential_ to
> becoming a programmer. I'm not sure how you think that giving someone
> an answer will ever help them be able to answer similar questions
> themselves. The process followed to achieve the solution is what is
> important here, not the solution itself.

Right.  But you are concluding that only by figuring out
the process by reconstructing it from hints can it be
learned.  I disagree with that and maintain that you
can show someone a solution, and they can figure out
quite well, seeing the answer worked out, how to get
similar answers in the future.  In more detail...

[Disclaimer: I know nothing about educational methods
beyond what I have experienced -- these are my personal

There are (at least) two ways to learn something.  You
can adopt an experiential approach by trying to repeat
the "discovery" of the knowledge (guided by a teacher
to avoid wasting time, get past too-hard parts, etc).

Another way (probably more common) is to simply have
someone tell you the facts and you make the effort to
remember them and integrate them with what you already

The first seems to work well when one is facing a large
body of knowledge that one is learning about for the
first time, more or less independent of anything else
in one's life (e.g. the typical collage course).

The second seems to working well when you already
have a surrounding knowledge structure to integrate
the new information with, for example a specific
problem you are trying to solve.

I would also imagine that individual people have a
bias toward one or the other approaches as well.

It seems to me that the conceptual barrier facing the
OP was thinking he had to look at each digit of his
number separately.  The two key bits to getting past
that is, "consider the number as a string", and (what
MRAB said), "It's a palindrome if it's [string is] the]
same as its reverse."

Everything past that are python-specific implementation
details, specifically conversion of numbers to strings,
the existence of the reversed function, and how to
deal with the funky value returned by reversed.

My guess was the conceptual barrier was the big one,
and although the OP was learning Python, was likely
to be able to learn about the parts of Python needed
to implement a solution simply by looking at a solution
(and reading the docs regarding the bits and pieces,
str(), reveresed(), join(), etc) -- no need to jump
though a bunch of hoops set up for him by (well-
meaning) people copying a pedagogy developed for use
in a completely different environment.

Again, I am *not* saying my evaluation of the OP's
needs is correct, only taking issue with your (and
several other's) seeming insistence that *only* the
experiential response was appropriate.

Repeating what I said in my previous post:
Different people have different goals and learning
styles.  Choice is *good*.

> Give a programmer a code fragment, and you've helped him for a day.
> Teach a programmer to code, however...

Yes, but be sure you're dealing with a programmer first,
and not someone who just wants to use a program to help
solve a problem.

More information about the Python-list mailing list