Type of repetition

--Originally published at codemathblog.wordpress.com

For read this post you need to know about loops (for and while functions) so you can understand better when to use each one.

Here we have an example of a for loop:

for

And here we have a while loop:

edad

In a for loop you kind of know how many times your loop will repeat, you have the number! meanwhile in a while loop you don’t know how many times it will repeat because it will be running until the condition is not true.

As simple as that!  for=n times   whilee= no idea how many times

Hope it was useful! I will let you some links where you can look for more information:

http://stackoverflow.com/questions/920645/when-to-use-while-or-the-for-in-python

https://www.quora.com/Why-would-you-use-the-while-statement-when-if-statement-does-the-same-without-having-to-loop-in-Python