weird strings question
Robert Kern
rkern at ucsd.edu
Fri Feb 25 20:57:17 EST 2005
Lucas Raab wrote:
> Is it possible to assign a string a numerical value?? For example, in
> the string "test" can I assign a number to each letter as in "t" = 45,
> "e" = 89, "s" = 54, and so on and so forth??
Use a dictionary with the strings as keys.
string2num = {}
string2num['t'] = 45
string2num['e'] = 89
etc.
--
Robert Kern
rkern at ucsd.edu
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
More information about the Python-list
mailing list