Why Python don't accept 03 as a number?
rosuav at gmail.com
Mon Dec 10 06:38:52 EST 2018
On Mon, Dec 10, 2018 at 10:31 PM <jfong at ms4.hinet.net> wrote:
> Chris Angelico於 2018年12月10日星期一 UTC+8下午7時09分01秒寫道：
> > Yet most human beings will agree that you don't write out an
> > arithmetic problem as:
> > 0 1 9 8
> > + 7 1 3
> > =========
> Python3 gives me the error message is because of the number 0198, not because of 0198 + 713.
As would humans, yes. You don't write numbers with leading zeros in
normal grade-school arithmetic. Or at least, I was taught not to.
(Except in special circumstances.)
> > > I prefer to buy the reason that this restriction was bring in is because of the puzzle's author know it will cause trouble without this, not because of our written habit.
> > >
> > No, it's a restriction because it is unsatisfactory without it. The
> > point of a puzzle is to be fun, and fun means having restrictions that
> > fit what people expect.
> The fun is from solving the puzzle, not from its restriction, unless the puzzle has no fun without this restriction.
Okay. Here, solve this one.
send + more = digits
There are absolutely no restrictions. A letter could represent the
square root of negative one, or the base of natural logarithms, or
anything at all. Is that fun? Or would you prefer to have normal and
Restrictions are there to create fun. Restrictions make it into an
interesting puzzle instead of a "gotcha" that makes you feel stupid
when someone points it out (for instance, you say "there's no
solution" and someone says "ah ha, but you see, the letter 's'
represents the colour green, not a digit").
In terms of game/puzzle design, the restriction is a good one. In
terms of programming language design, it's also a good restriction,
though for different reasons (mainly the conflict between the
C-derived expectation and the human-derived expectation, and the
subtle confusion that would be caused).
More information about the Python-list