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
Post a Comment