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

1890 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

Using the shared code editor, write a recursive function for calculating a factorial of an input parameter.


How can you take a list of numbers and add 3 to every number in the list using only one line of code?


Write a short program to print all the even numbers 1 to 100


Give an example of a FOR 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