[Tutor] General construction of alpha lists?
Danny Yoo
dyoo at hkn.eecs.berkeley.edu
Wed Oct 22 02:03:26 EDT 2003
On Tue, 21 Oct 2003, Clay Shirky wrote:
> Next stop, making it possible to generate an alphabetical list, based on
> the array number. I'd like to do something like
>
> class_groups = range(12)
>
> and then have it print from A through L.
Hi Clay,
Yes, there's a nice way to do it. Karl Fast's approach is probably the
best one. But if we didn't have that nice string constant handy, we can
still do it easily.
Here are two ingredients:
chr() -- http://www.python.org/doc/lib/built-in-funcs.html#l2h-15
ord() -- http://www.python.org/doc/lib/built-in-funcs.html#l2h-56
With some list manipulation, you should be able to cook something up
pretty nicely. *grin*
Talk to you later!
More information about the Tutor
mailing list