lists....order...

Mark McEahern marklists at mceahern.com
Wed Oct 9 22:48:14 EDT 2002


> how does enumerate work?

Aw, why'd ya have to make me go and figure out how to access Python's CVS so
that I could install Python 2.3 and see fer myself?  <wink>

Cheers,

// m

$ python2.3
Python 2.3a0 (#1, Oct  9 2002, 21:35:16)  #<-- Yup, just installed it.
[GCC 2.96 20000731 (Red Hat Linux 7.3 2.96-112)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import string
>>> for i, letter in enumerate(string.letters):
...     print "%d --> %s" % (i, letter)
...
0 --> a
1 --> b
2 --> c
3 --> d
4 --> e
5 --> f
6 --> g
7 --> h
8 --> i
9 --> j
10 --> k
11 --> l
12 --> m
13 --> n
14 --> o
15 --> p
16 --> q
17 --> r
18 --> s
19 --> t
20 --> u
21 --> v
22 --> w
23 --> x
24 --> y
25 --> z
26 --> A
27 --> B
28 --> C
29 --> D
30 --> E
31 --> F
32 --> G
33 --> H
34 --> I
35 --> J
36 --> K
37 --> L
38 --> M
39 --> N
40 --> O
41 --> P
42 --> Q
43 --> R
44 --> S
45 --> T
46 --> U
47 --> V
48 --> W
49 --> X
50 --> Y
51 --> Z
>>> print enumerate.__doc__
enumerate(iterable) -> create an enumerating-iterator
>>>

-





More information about the Python-list mailing list