LIST IN 2D
Tables are two-dimensional data structures where we can store data both vertically and horizontally.
Eg:my2DList = [ ["Johnny", 21, "Mac"],
["Sian", 19, "PC"],
["Gethin", 17, "PC"] ]
print(my2DList[2][2])
Editing a 2D List
We can edit values in a 2D list in the same way as variables and 1D lists. You just need to change the value to the new row and column index numbers
Eg:
my2DList = [ ["Johnny", 21, "Mac"],
["Sian", 19, "PC"],
["Gethin", 17, "PC"] ]
my2DList[1][2] = "Linux"print(my2DList[1])
Comments
Post a Comment