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

1763 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

How do I use format python code?


What are the main data structures that I can use in Python


[Student query] Why do we import libraries/modules such as Numpy and Matplotlib into Python?


Make a program that asks the user for a series of numbers until they either want to output the average or quit the program.


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:

© 2025 by IXL Learning