Like this article? You must log in first!

When Do You Use For Loops and While Loops?

Categories: Tech | Pubby Cash Received:  0 | Click to Award

Many programmers don’t really understand why there are two different loops and why they are used in the way they are. Probably the most common type of loop, for loops, are great for when you already know how many times you want to loop through something. When using a for loop, we typically use a counter that will either increment or decrement until a condition is met. Once the condition is met, the loop will stop. A while loop is slightly different than a for loop for the fact that it’s good to use when we don’t know how many times we want to loop through a problem beforehand. This is the key difference between using a for loop or a while loop. Either way, both loops can do the same thing, but for loops are better in situations where you want consistent repetition. This detailed book will extensively cover all of the fundamentals about loops and so much more in Python programming!


Published from: Pennsylvania US
Liked by: H2O, Evan Tang 

Daily Deals


MECHANICSBURG WEATHER