dx="abcdefghijklmnopqrstuvwxyz" d=[] for d1 in dx: d.append(d1) w="sigma" p=2 ch="" for w1 in w: sx=d.index(w1) sx=sx+p if sx>25:sx=sx-25 ch=ch+d[sx] print(ch) px=-p rev="" for w1 in ch: sx=d.index(w1) sx=sx+px if sx>25:sx=sx-25 if sx<0:sx=sx+25 rev=rev+d[sx] print(rev)