Range function



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]


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


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


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