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

Related Python Mentoring answers

All answers ▸

How can you take a list of numbers and add 3 to every number in the list using only one line of code?


Write a function that takes a list of numbers as input, and outputs the average of the numbers. The function should catch any errors.


How might we implement the bubble sort algorithm in Python


How do For Loops work?