What is the difference between a for and a while loop?

A for loop iterates over set commands within the loop (need to be indented), executing this block of code in order until prompted to stop (as specified). A while loop is used when a condition needs to be checked each iteration before the loop can run through the block of code.

TD

Related Python Mentoring answers

All answers ▸

Generate an array of integers from 0 to 99 and split it into two smaller arrays. Each smaller array will contain half of the original.


Create a program that checks for syntactical errors in an email address.


Sort a given input of lowercase letters alphabetically


Give a segment of python code that will print the numbers 1 to 7, each one on a new line