+ 1
Lists
What is the purpose of having two brackets around a list? For example List = [[a, b, c]]
4 Respostas
+ 3
Let me give you some examples.
lst = [1, 2, 3]
list = [[1, 2, 3]]
lst has three elements, but list has 1.
lst.append(list[0])
now,
lst = [1, 2, 3, [1,2,3]]
so, it has 4 elements now.
Hope it helped
+ 1
Your example is a list within a list = a nested list: The inner list contains a, b, c while the outer list contains the inner list.
[[a, b], c]
In thos example, the outer list contains a list (containing a and b) and c
0
points=[[3,7],[2,3],[4,8]]
could be a list of points with x and y coordinates.
0
wow. this community is awesome. thanks everyone.