We can rewrite the knitting example from earlier in the term, replacing the while loops with nested for loops as follows: