--Originally published at Welcome to the Heaven
In this post you will learn how the function range acts. Is very common use this function in a loop when you want to the loop perform an action N number of times, also we can see it when we want to make operations with numbers or print specific values of a list/tuple.
Let’s see a picture with some examples, an after that I will explain you how it works at each case.
As you can see in the title of this post ([start],stop,[step]), describes the way that act the first example. The range function always start form 0, so 0=first value. Start from 0 and the next number is going to be two numbers after.
The second one and third one are the same, but I put it just because these are the two ways to write a range, but if you want to be more professional you must use the second one.
The last one is the same as the first but with a difference in print. end=” ” makes that the function doesn’t go to the next line.
And if you want to see another example with the power of two range loops:
With this little code we can do this: