Open datasolver opened 5 years ago
Thanks, Jamiu! You're right and, in fact, you hit a very important issue that we've got in our episode on for
loops: indentation is not emphasized enough. The word indent
occurs only twice in the episode: once in the body of the lesson, and once in keypoints. I suggest to discuss how to go about this and then... submit pull request(s)!
I think there's a perfect opportunity to discuss it in the segment after "What's in a name". The lesson already calls for following the loop step by step to see how indented code inside the loop changes the variable defined outside the loop, I think one extra example to demonstrate how indenting the last line changes the output would fit in nicely. Potentially even squeezing in a 3rd example to demonstrate that users need to be consistent with their indentation?
One of the key problems I had when I started programming (in python) was with indentation especially with "for loops" and "if statements". I believe most beginners will have the same or similar issues. Therefore, I think this lesson (Programming with Python : Repeating actions with loops) is a golden opportunity to let learners have a feel of what problems they can run into without proper indentation. For example, how will the intended answer be affected if:
This code:
was written as: