[Tutor] Tkinter grid question

Phil phil_lor at bigpond.com
Fri Apr 7 04:33:31 EDT 2017


On Fri, 07 Apr 2017 10:01:21 +0200
Peter Otten <__peter__ at web.de> wrote:

> > e = [None] * 6 , [None] * 2
> 
> In the above line you are creating a 2-tuple consisting of two lists:
> 
> >>> [None]*6, [None]*2
> ([None, None, None, None, None, None], [None, None])
> 
> What you want is a list of lists
> [
> [None, None],
> [None, None],
> ...
> ]
> 
> You can create such a list with
> 
> >>> [[None] * 2 for _ in range(6)]
> [[None, None], [None, None], [None, None], [None, None], [None,
> None], [None, None]]
> 

Thank you Peter, that makes sense.

What I'm trying to do is convert a sudoku solver that I wrote using C++ and the QT library in 2005. As well as coming to grips with Tkinter I'm having trouble following my C++ code.

-- 
Regards,
Phil


More information about the Tutor mailing list