--Originally published at Elu's Blog
We have three repetitive functions in Python3:
- For loops. In Python3 ‘for loops’ are best used when you want to edit or analyze a string, list, tuple or dictionary which number of things in it is defined. In other languages like C, ‘for loops’ and ‘while loops’ are used by preference of the programmer, they are interchangeable.
- While loops. They are used when the times of the repetition vary.
- Recursion. They are used when the solution to a problem is defined by the solution to smaller instances of the same problem.
As easy as that, you want to analyze a list? Use a for loop. Want to print as many ‘Hello World”s as the user wants? Use a while loop. Want to get a fibonacci number in a series? Use a recursive function.
Here are links to explanation of every repetitive function:
For loops: https://elusblog.wordpress.com/2017/02/14/wsq04-for-loops-python3/
While loops: https://elusblog.wordpress.com/2017/02/14/wsq06-while-loops-python3/
Recursive functions: https://elusblog.wordpress.com/2017/04/20/recursion-python3/
![](https://pixel.wp.com/b.gif?host=elusblog.wordpress.com&blog=122618435&%23038;post=752&%23038;subd=elusblog&%23038;ref=&%23038;feed=1)