There are two little things that I think would make it better.
You lowercased my comment on line 3. The new phrasing is fine, but I try to start comments with capitals.
The check method is clearly a good idea. That's why it is the first exercise after this example. If we put it right in this file, I can't leave it as an exercise for the learner.
Sequential invocation of the counter by means of nested for comprehensions