EC Lecture Notes - Lecture 5: Tuple, Exclamation Mark, Lightning
Document Summary
Lists are one of 4 built-in data types used to store collections of data, the other 3 are tuple, set, and dictionary. We can create a list by using square brackets with commas separating items. In that example the words list contains three string items: hello, world and ! If you want to access a certain item in the list, you can do this by using its index in square brackets. For example: words = ["hello", "world", "!"] print(words[0]) print(words[1]) print(words[2]) We can do some pretty cool stuff with them in python. For example, we can use nested lists to represent 2d grids, such as matrices. This is useful because a matrix-like structure can allow you to store data in row-column format, like in ticketing programs, that need to store the seat numbers in a matrix, with their corresponding rows and numbers. The code above outputs the 3rd item of the 2nd row.