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

A for loop iterates over set commands within the loop (need to be indented), executing this block of code in order until prompted to stop (as specified). A while loop is used when a condition needs to be checked each iteration before the loop can run through the block of code.

TD
Answered by Tutor143011 D. Python tutor

1517 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

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


What is Object-Oriented Programming?


What would output this code? print(hello world)


Firstly, my question is not Python related, but maths A-level related. I don't know how to change that in my profile but I would like to only tutor maths GCSE and potentially A-level. My question: Integrate sin(x)^3 over x=0 and x=pi/2.


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