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 might we implement the bubble sort algorithm in Python


Write a function that takes a string, and outputs that string formatted in camelcase. (alternating upper and lower case for each character, e.g. cAmElCaSe)


Create an rock, paper, scissors game. The user should input one option, and the computer should play randomly.


How would you get a piece of code to print the numbers 1 to 10