Example
While Loop Basics
While loop executes as long as condition is true. Controlling iteration with condition.
Showing 1–10 of 57
Example
While loop executes as long as condition is true. Controlling iteration with condition.
Example
For loop iterates through sequence elements. Basic iteration over lists.
Quiz
Free beginner quiz on Python while loops: 15 questions on conditions, counters, infinite loops, break and continue, with instant answers.
Quiz
Free beginner quiz on Python for loops: 15 questions on lists, strings, range(), enumerate(), totals and break, with instant answers.
Example
…(exit) and continue (skip) statements for flow control in loops.
Article Python Fundamentals
Nested loops let you work with 2D data like grids, tables, and images. Learn how they work, avoid common pitfalls, and write cleaner Python code with real examples.
Challenge
A while loop waits for the antenna signal but never moves on to the next reading, so it never ends. Predict it, find the stuck counter, fix it, then write a wait that gives up when the readings run…
Example
Functions enumerate() and range() extend for loop capabilities in Python.
Challenge
…blocks with a list of (name, level) pairs and one loop, keeping the output exactly the same, then add a fourth tank with a single list item and list the low tanks.
Challenge
…on line 4: [T+00:14:47] ERROR Fuel valve 2 not responding Loop with enumerate(log, start=1) . Look for "] ERROR" , as in "Count warnings", so a message that only mentions the word doesn't count. break…