Range function


#1

Hello,

I am confused in the third version of range() function. First two types i understood but how this third one works?

range(start, stop, step)
range(1,6,3) # => [1,4]


#2

by default steps are 1 in range. so this:

range(1,6) # => [1,2,3,4,5]

which is the same as:

range(1,6, 1) # => [1,2,3,4,5]

however, if we now make steps of 2:

range(1,6, 2) # => [1,3,5]

steps is how much we increase, by default this one, but we can change this


#3

Thank you brother for your help. Hope to expect such effort in future also.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.