Learning Python: Part 6: Loops

Learning Python

Python is a general-purpose interpreted programming language. It emphasizes readability through the use of whitespace and supports multiple programming paradigms such as functional and object-oriented models.


To help with tasks that need to repeat or continue until something happens, there is a programming concept called loops.

In Python, loops look like functions in structure but work in a different way. They have their keywords, what to test, and end in a colon. The code to run in the loop is “under” (tabbed from the left margin).


A while loop works on conditional statements. For as long as the statement is true, the loop will continue to run.

For… in…

The forin… keywords are primarily used for running in fixed cycles. They are often used in conjunction with lists (for moving through them one-by-one) or in fixed ways using another function, range().

Play with the example on Repl.it!