Week 2

Loops

A program can repeat, keep a list, or look something up.

A loop repeats. While keeps going as long as a test stays true. For walks a sequence: the letters of a word, the items in a list, or a range of numbers. Break leaves the loop early. Continue skips to the next round. Len tells you how many things are in a list or a string.

A list keeps items in order. A dict keeps a value under a name, so you can look it up. None means 'no value', which is different from zero and different from an empty string. If you only need to remember one thing while you loop, a single variable is enough. If you need every answer, keep a list.

A fresh example: ask a friend for colors until they say 'stop', and store the colors in a list. That is a loop plus a list. It is not one of the problems.

The idea
Ask again until you are done Ask once Keep what you need again

Problems