Repeat Yourself

Learn how to use loops to repeat code.

What if we wanted to plant 10 trees, send 5 reminders, or greet each student in a list without copying the same line of code repeatedly?

Instead of repeating the same line repeatedly, Python lets us loop through actions with just a few lines!

The for loops: Do it a set number of times

A for loop lets us repeat actions several times, saving time and keeping our code clean and powerful. It is perfect for knowing how many times we want something to run.

Get hands-on with 1400+ tech skills courses.