Welcome, guest | Sign In | My Account | Store | Cart

Creates a caesar cipher function which shifts by the parameter.

Usage:

f=caesar(2)

f("abcde")

returns "cdefg"

Python, 2 lines
1
2
def caesar(n):
    return lambda s:("".join(map(lambda x:(chr((ord(x.lower())-97+n)%26+97)),s)))
Created by span on Wed, 23 Nov 2011 (MIT)
Python recipes (4591)
span's recipes (1)

Required Modules

  • (none specified)

Other Information and Tasks