+ 1
Can you explain this code to me?
Range(0,100,5)
3 Respostas
+ 3
Mike Harris
The above code creates a range of numbers, in this case from 1 until 99.
The last parameter is the ‚step‘. It tells python to use every fifth element from that range.
So in this case, you would not have 1,2,3...99
But rather:
1,6,11,16,21...96
Hope this helps :)
+ 3
range(0,100,5)
does start with 0 followed by 5,10,15,... and ends with 95 as stop value is up to 100 but not including this value.
0
Just do this
Print (list(range(100))) and
Print(list(range(0,100))) and print(list(range(0,100,5)))
You will know yourself what's exactly is range(0,100,5)
If in depth of range:0 is start( by default 0)
100 is stop and 5 is step