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

1461 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

Manually implement a function that finds the smallest value in a list of integers and print it.


When to use a dectionary or a list


Define a function that takes in the age of the user and adds it to an output sentence such as "You are ..... old".


Write a simple number guessing game, give the user 3 tries to guess a number between 1 and 10


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