Convert numbers into corresponding letter using Python -


i wondering if possible convert numbers corresponding alphabetical value. so

1 -> 2 -> b 

i planning make program lists alphabetical combinations possible length specified user.

see know how build rest of program except this! wonderful.

import string x, y in zip(range(1, 27), string.ascii_lowercase):     print(x, y) 

or

import string x, y in enumerate(string.ascii_lowercase, 1):     print(x, y) 

or

for x, y in ((x + 1, chr(ord('a') + x)) x in range(26)):     print(x, y) 

all of solutions above output lowercase letters english alphabet along position:

1 ... 26 z 

you'd create dictionary access letters (values) position (keys) easily. example:

import string d = dict(enumerate(string.ascii_lowercase, 1)) print(d[3]) # c 

Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -