I use a shopping basket and then `for item in basket`. The fact that the item could be a single thing or a carton of eggs (=list), which could also be looped through, helps. I think the point about not using `egg` as the variable name is extremely import. If you say `for line in myfile` they think `line` is a magic word that grabs a line and `word` or `letter` would act differently. The main conceptual hang up seems to be how the variable gets reassigned each time. It is also not "proper convention" and freaks out CS people, but I like to capitalize the variable names, so it is easier to distinguish special Python words from arbitrary names. -Steve ----- q•b -----
> On Dec 3, 2015, at 01:24, Karin Lagesen <karin.lage...@gmail.com> wrote: > > The more I teach, the more I realize that I am not really able to convey what > a for loop does to everybody. Do any of you have a metaphor or something that > you use for teaching it? I explain about variables and collections, and the > body of the loop, and I show examples, but I am still not able to get through > all the time. > > Karin > > _______________________________________________ > Discuss mailing list > Discuss@lists.software-carpentry.org > http://lists.software-carpentry.org/mailman/listinfo/discuss_lists.software-carpentry.org _______________________________________________ Discuss mailing list Discuss@lists.software-carpentry.org http://lists.software-carpentry.org/mailman/listinfo/discuss_lists.software-carpentry.org