Lesson 13: Decision making: if, elif and else
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…
Blog
29 lessons, in order — start at lesson 1 and work down.
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…
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()…
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 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…
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 tuple is an ordered collection that cannot be modified after it is created. That restriction is the point: it is safe to share, cheap to unpack, and the natural…