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

1644 Views

See similar Python Mentoring tutors

Related Python Mentoring answers

All answers ▸

Use recursion to print all the sublists of a given list


Write a function that checks whether a number is prime or not.


Using the shared code editor, write a recursive function for calculating a factorial of an input parameter.


What is the outcome of the following code? print(2*[3,4,5])


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