2 ms·
> Figuring out loops Maybe you're making it too complicated. The reason for loops is simply that you need to repeat an operation. Call it repetition if that
by mixmastamyk 8y ago
> Figuring out loops
Maybe you're making it too complicated. The reason for loops is simply that you need to repeat an operation. Call it repetition if that helps.
- for x;y;z - repeat a specific number of times, or need an index #
- for x in y - iterate over container
- while x - repeat while a condition is true
- do while x - like while, but run at least once.
So, imagine we have a string and need to add 1 to each character. The second bullet above looks best, first if the language is lower level.