how to take a number and find its alphabet position python

Viewed 13750

So far, I have been able to take a letter and find it's number position. Example, a == 0 But now I want to take that number, and add 4. Then return the alphabet equivalent of that number. So, a == 0; 0 + 4 = 5; should return f. Cause that is fifth in the alphabet! Here is my code so far:

def convert_int(str):
    a = string.lowercase.index(str)
    addition = a +13
    return addition;
3 Answers
import string

alphabet=string.ascii_lowercase
#alphabet='abcdefghijklmnopqrstuvwxyz'

#print char by position: ex: 4 
 print(alphabet[4])
#This will print e 
Related