Solves: doing things a fixed number of times or processing every element of a list.
In this introductory lesson, we only show how to repeat code a fixed number of times using the range() function. We can present the range function as producing a list of numbers.
It allows us to first introduce the concept of for loops and later build upon it with lessons dedicated to arrays.
Unlike while loops, for loops do not run infinitely, so it is much less likely that you will get bugs in your game. Because of that, we recommend favoring for loops over while loops.
To cover:
- Looping a fixed number of times (range)
Solves: doing things a fixed number of times or processing every element of a list.
In this introductory lesson, we only show how to repeat code a fixed number of times using the
range()function. We can present the range function as producing a list of numbers.It allows us to first introduce the concept of for loops and later build upon it with lessons dedicated to arrays.
Unlike while loops, for loops do not run infinitely, so it is much less likely that you will get bugs in your game. Because of that, we recommend favoring for loops over while loops.
To cover: