for y in range (0,iNumItems)--> not in order?
Larry Bates
larry.bates at websafe.com`
Thu Aug 14 11:05:59 EDT 2008
korean_dave wrote:
> for y in range(0,iNumItems):
> print(str(y))
>
> How do i make the output go IN ORDER
> 0
> 1
> 2
> 3
> 4
> 5
> 6
> etc.
>
> instead of
> 0
> 1
> 10
> 11
> 12
> 13
> 14
> 2
> 3
> 4
> 5
> 6
> 7
> 8
> 9
That's not what it does on my system (Python 2.5.2 on Windows). Please post the
code that you are "actually" running.
>>> for y in range(15):
... print str(y)
...
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
You must have put them in a list and sorted them prior to printing them to get
the output you show. If you sort the list, the output is correct. To make it
different, you will need to pass sort a custom cmp function.
-Larry
More information about the Python-list
mailing list