I want to convert a string to numbers ... i tried a lot of codes.. iam a beginner...

Kindly help...


a=1 b=2 c=3 d=4 e=5 f=6 g=7 h=8 i=9 j=10

input value -->abc output value --> 123

input value -->abcj output value -->12310

I mean i want to output the alphabet position of the string to the numbers

Also, i want to have a html page GUI to input the value and get the output


Does this help?

>>> import string
>>> dd = dict(zip(string.ascii_lowercase, [str(i) for i in range(1,27)]))
>>> "".join([dd[s] for s in "abcdejz"])

Looks familiar, I posted to similar question earlier in Stackoverflow:

base = ord('A') - 1
mystring = 'ABC'
print sum(ord(char) - base for char in mystring)

That has best score, but is not accepted answer in

That can adapt to simply joining the letters also:

base = ord('a')-1
for mystring in ('ABC','abcj'):
    print ''.join(str(ord(char.lower()) - base) for char in mystring)

Yes...THats wat i want.. thanks guys..