[Tutor] Creating Sudoku
Andrei Petre
andrei.petre at gmail.com
Mon Apr 7 18:01:38 CEST 2008
A good place to look at : http://www.norvig.com/sudoku.html
On Mon, Apr 7, 2008 at 6:53 PM, Luke Paireepinart <rabidpoobear at gmail.com>
wrote:
> W W wrote:
> > On 4/7/08, Luke Paireepinart <rabidpoobear at gmail.com> wrote:
> >
> >> W W wrote:
> >> What are you talking about? I don't understand what you mean by
> "ignores
> >> whitespace between dictionary elements."
> >>
> >>
> >>> foo = {'1a': 1, '1b':2, '1c':3,
> >>> '2a': 0, '2b': 9, '2c': 6}
> >>>
> >
> > Exactly that. If you were to write:
> >
> > foo = {'1a': 1, '1b':2, '1c':3}
> > foo['2a'] = 0
> >
> > You would get a nifty error.
> >
> You mean that the dictionary _definition_ ignores whitespace between
> elements?
> That's quite different than the dictionary itself ignoring whitespace.
> That implies that
> foo['1b'] is the same element as foo['1 b'], hence the source of my
> confusion.
>
> That's not a feature of dictionaries, but of the comma.
> You can easily do the following:
> x = [1, 2,
> 3, 4]
> if you want.
> Same with tuples and various other things.
> Python just realizes that if it doesn't see a closing brace/bracket, but
> sees a comma, that more will probably be coming on the next line.
> You can do the same thing with backslash, if your statement does not end
> in a comma: for example,
> x = 1 + 1 + \
> 2 + 3 + 5 \
> + 8 + 13
>
> Also, did you test the code that "generates an error?"
> It works fine for me.
> >>> foo = {'1a': 'b'}
> >>> foo['2b'] = 0
> >>> print foo['2b']
> 0
> >>>
>
> Hope that helps,
> -Luke
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20080407/15f4f6a7/attachment.htm
More information about the Tutor
mailing list