[Tutor] range() help
Jan Erik Moström
lists at mostrom.pp.se
Tue Apr 17 13:57:18 CEST 2007
Reply to python at uni-code.com 07-04-17 07:42:
>How come it prints on -40 or -70.
>
>Does -70 come from -70 -> -100?
>
>This is really confusing me.
I don't really understand your question, the definition of range
range(...)
range([start,] stop[, step]) -> list of integers
Return a list containing an arithmetic progression of integers.
range(i, j) returns [i, i+1, i+2, ..., j-1]; start (!)
defaults to 0.
When step is given, it specifies the increment (or decrement).
For example, range(4) returns [0, 1, 2, 3]. The end point
is omitted!
These are exactly the valid indices for a list of 4 elements.
So you are basically telling python to start from -10, and then
subtract -30 until it reaches -100.
More information about the Tutor
mailing list