← Courses

Python for AI — Beginner Foundations

Data Science

Basics · Lesson 27 of 76

Loops

A loop repeats work so you don't write the same line over and over. for walks through a sequence:

Python

You can loop over the items in a list too:

Python

Your turn: print the 3 times-table from 3 to 30 using a loop.

Check your understanding

Exercise — check your understanding

Use a loop to add up the numbers 1 to 5 into total.

You’re reading for free. Sign in to keep your progress and earn a certificate when you finish.Sign in to keep my progress →