[Tutor] Print random letters
dyoo at hkn.eecs.berkeley.edu
Thu Dec 22 01:08:33 CET 2005
> I want to print out random letters from A - Z. I know how to do this
> with numbers, but don't know with letters.
There's a "mapping" between numbers and letters through the ord() and
chr() built-in functions. ord() takes in a character and returns a
number, and chr() takes in a number and returns a character.
>>> chr(97 + 25)
So yet another approach might be to take what you already know --- getting
random numbers --- and just translating those numbers to characters.
Best of wishes to you!
More information about the Tutor