Caesar Cipher

  • + 0 comments

    def caesarCipher(s, k): alp ="abcdefghijklmnopqrstuvwxyz" if k>2: if k>26: k= k%26 ro = alp[k:]+alp[:k] j= list(s) lt = []

    for i in j:
        if i.lower() not in alp:
            lt.append(i)
        elif i.isupper():
            k= alp.index(i.lower())
            lt.append((ro[k]).upper())
        else:
            k= alp.index(i)
            lt.append(ro[k])
    fin = ''.join(lt)
    return fin