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

1615 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

How might we implement the bubble sort algorithm in Python


Why are negative indexes used?


Explain why creating a list of several instances of one element using something like my_list = [a] * 5 can result in strange behaviour


What built-in types does python provide?


We're here to help

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

© MyTutorWeb Ltd 2013–2025

Terms & Conditions|Privacy Policy
Cookie Preferences