Caesar Cipher

  • + 0 comments
    def caesarCipher(s, k):
    low='abcdefghijklmnopqrstuvwxyz'
    up= low.upper()
    new=''
    
    for i in s:
        if i in low:
            real_r= (low.index(i)+k)%26
            new+= low[real_r]
        elif i in up:
            real_r= (up.index(i)+k)%26
            new+= up[real_r]
        else:
            new+= i
    return new