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
Answered by Tutor143011 D. Python tutor

1892 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

Creating string from multiple strings(or characters)


Write a recursive function that takes any integer n and prints the nth Fibonacci number.


Print "Hello World!" ten times without typing (or pasting) the print function more than once


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


We're here to help

contact us iconContact ustelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo

MyTutor is part of the IXL family of brands:

© 2026 by IXL Learning