loading...

re: Daily Challenge #42 - Caesar Cipher VIEW POST

FULL DISCUSSION
 

Python :

def cypher(m, key):
    m_cypher = ''
    for i in m:
        if i != ' ' and i != '.':
            m_cypher += chr(ord(i) + key)
        else:
            m_cypher += i
    return m_cypher

One line :

cypher = lambda m, key : ''.join(chr(ord(i) + key) if i != ' ' and i != '.' else i for i in m)
code of conduct - report abuse