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.

Answered by Molly I. Python tutor

1559 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

Write a program that can convert between celcius and farenheit temperature scales


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


Demonstrate a recursive solution to calculate the factorial of a number


Explain how you would write a python program that takes a rectangle and a point in a 2D space as command-line arguments and checks if they intersect.


We're here to help

contact us iconContact usWhatsapp logoMessage us on Whatsapptelephone icon+44 (0) 203 773 6020
Facebook logoInstagram logoLinkedIn logo

© MyTutorWeb Ltd 2013–2025

Terms & Conditions|Privacy Policy
Cookie Preferences