Guided Notes
Lists & Dictionaries
Lists, indexing and slicing, list methods, tuples, and dictionaries.
Lists, indexing, and slicing
Slide 1 / 5A list is an ordered collection in square brackets: primes = [2, 3, 5, 7]. Lists can hold any type ā even other lists.
Python counts from 0: planets[0] is the first item, and negative indexes count from the end, so planets[-1] is the last.
Slicing returns a sub-list: planets[0:3] gives items 0, 1 and 2 ā the end index is excluded. planets[:3] is the first three, planets[3:] everything from index 3, and planets[-3:] the last three.
