([start],stop,[step])

--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.

screen-shot-2016-11-27-at-2-35-18-am

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:

screen-shot-2016-11-27-at-2-37-06-am

With this little code we can do this:

screen-shot-2016-11-27-at-2-40-49-amscreen-shot-2016-11-27-at-2-40-58-am

Source.