I'm currently creating my own FOSS platform/course for teaching Python to beginners: https://github.com/alexmojaki/python_init (sorry, it's very new and under construction so there's no docs yet). The content moves to for loops relatively quickly, and for quite a while the only thing they loop over is strings. It's a great way to make all sorts of fun exercise and build foundations. So I'm aware of its educational value, and I know this would be a pity in that sense. I would simply update my course to start with: for letter in "some word".chars(): print(letter) and explain that ".chars() simply means that you want the characters of the string - don't worry about what the . and () mean for now" (although I'm against requiring () anyway). When they inevitably forget to include .chars() somewhere, they will immediately get a warning telling them to put it back, and since they've seen chars() used before, the warning will be easy enough to understand. By the time they see indexing used on strings in my course, chars() will be an old friend. The journey I've presented is one where the user hasn't already been shown iteration over a string and discovers it for themselves, because that is the scenario which seems most likely to cause confusion and thus it's the most favourable to Chris' argument and the most damaging to mine. On Mon, Feb 24, 2020 at 9:22 PM André Roberge <andre.roberge@gmail.com> wrote:
On Mon, Feb 24, 2020 at 3:01 PM Alex Hall <alex.mojaki@gmail.com> wrote:
Snip
From the assumptions in this scenario, we're talking about a beginner - specifically one who might have trouble understanding the kinds of things we're discussing, and who has never iterated over a string before (which, if I am to be generous to your side, is supposedly a common activity).
Context: I recall a conversation on the edu-sig group (Python in education) about teaching beginners. I was arguing that, when teaching in visual-based environment (think Karel the robot or the turtle module), when introducing loops, it would be useful to have something like "repeat n: move()" instead of "for irrelevant_name in range(n): move()". (This is something I have implemented in Reeborg's world and that has also been independently added in TygerJython)
Someone (I believe it was Laura Creighton - sorry, I cannot find the link right now) mentioned that the very first example of loops they used was something like the following:
for letter in "some word": print(letter)
If I recall correctly, quite a few other people teaching beginners also mentioned that this was one of the first, if not the first example they used. In fact, I think I was in the minority in not using this type of iteration over strings as an early example of loops.
So, I would argue that iterating over strings with beginners is something much more common than what you appear to believe.
André Roberge