Download presentation
Presentation is loading. Please wait.
1
Nate Brunelle Today: Lists
CS1110 Nate Brunelle Today: Lists
2
Questions?
3
Last Time Loops in loops
4
Lists in lists x=[[1, 2], [3, 4, 5], [6]] len(x) -> 3 x[1] -> [3,4,5] len(x[1]) -> 3 x[1][0] -> 3 len(x[1][0]) Error
5
Example of lists in lists
Pictures are: A grid of pixels A grid is: A list of rows A row is: A list of pixels A pixel is: A list of 3 numbers (amounts of red, green blue) So a picture is: A list of lists of lists rows of pixels of 3 numbers
6
Identity, Alias Alias: another name for the same thing
7
New lists vs. Aliasing Creates a new list: Creates an Alias:
List-builder: [x, y, z] Slicing: mylist[start:end:step] Casting: list(collection) Creates an Alias: Assignment: mylist = myotherlist Invoking a function: func(mylist)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.