python: when making a list of lists do i have to contain them in square brackets? -


so whats difference between:

x = [1,1,1], [1,1,1], [1,1,1], [1,1,1] 

and

x = [[1,1,1], [1,1,1], [1,1,1], [1,1,1]] 

do square brackets around second option anything?

x = [1,1,1], [1,1,1], [1,1,1], [1,1,1] 

will create tuple lists

x = [[1,1,1], [1,1,1], [1,1,1], [1,1,1]] 

will create lists of list

i.e.)

x = [1,1,1], [1,1,1], [1,1,1], [1,1,1] x ([1, 1, 1], [1, 1, 1], [1, 1, 1], [1, 1, 1]) type(x) <type 'tuple'>  "a","b" ('a', 'b') 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -