Python code for calculating number of an alphabet -


i need find number of alphabet in range of alphabets ie = 1, b=2 , c =3.... if returning value should 1

is there shorter method provided in python(inbuilt) find other declaring dictionary of 26 alphabets respected values.

please if know of such function.....

use ord()

>>> c = 'f' >>> ord(c) - ord('a') + 1 6 

if want 'f' , 'f' both return 6, use lower()

>>> c = 'f' >>> ord(lower(c)) - ord('a') + 1 6 

you might interested in chr()

>>> c = 'f' >>> chr(ord(c) + 1) 'g' 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -