Lesson 17: Lists: the workhorse collection
A list holds many values in order and lets you change them. Append, insert, remove, pop and sort are the five methods that cover most work with lists.
Blog
Long-form pieces and opinion on technology, productivity and teaching.
A list holds many values in order and lets you change them. Append, insert, remove, pop and sort are the five methods that cover most work with lists.
A sequence is an ordered collection you can index, slice and loop over. Strings are sequences of characters, which is why the same tools — len(), slicing, in — work…
break leaves a loop immediately, continue skips to the next round, and pass does nothing at all. Each one is small, and each one has a place where it makes a loop…
A loop repeats work. Use for when you know how many times, or when you are walking through a collection; use while when you repeat until something changes. range()…
A program that always does the same thing is not much of a program. if runs a block when a condition is true, elif adds more cases, and else catches everything left…
When one expression holds several operators, Python applies them in a fixed order: power first, brackets above everything. These are the rules, with the three cases…