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

A for loop will run the code a predetermined number of times, whereas a while loop will continue to execute the code until a predetermined condition is met.

MI
Answered by Molly I. Python tutor

1914 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

Write a function s(n) that will return a list of the first n squares.


What is the outcome of the following code? print(2*[3,4,5])


[Exam style] Python is an interpreted language. Explain what this means and how interpreted languages differ from compiled languages.


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


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