In the Python Intro for Libraries Lesson: For Loops episode, it might be clearer to new learners if the first 2 blocks of code were reordered. When I've taught this lesson as a demo, I've done it this way and it seems to go very well. After the introduction on what a For loop does, show the steps the "long way" first, then demo the more elegant way of using a loop to accomplish the same task:
- print(2)
print(3)
print(5)
- This series of print statements is equivalent to a for loop:
for number in [2, 3, 5]:
print(number)
- And the output for both is the same:
2
3
5
In the Python Intro for Libraries Lesson: For Loops episode, it might be clearer to new learners if the first 2 blocks of code were reordered. When I've taught this lesson as a demo, I've done it this way and it seems to go very well. After the introduction on what a For loop does, show the steps the "long way" first, then demo the more elegant way of using a loop to accomplish the same task:
print(3)
print(5)
for number in [2, 3, 5]:
print(number)
2
3
5