シーザー暗号

Run Settings
LanguagePython
Language Version
Run Command
import string def cipher(a_string, key: int): uppercase = string.ascii_uppercase lowercase = string.ascii_lowercase encrypt = "" for c in a_string: if c in uppercase: # iが大文字ならば new = (uppercase.index(c) + key) % 26 encrypt += uppercase[new] if c in lowercase: new = (lowercase.index(c) + key) % 26 encrypt += lowercase[new] if (c not in uppercase) and (c not in lowercase): encrypt += c return encrypt a_str = "my name is Gaius Iulius Caesar." print(cipher(a_str, 3))
Editor Settings
Theme
Key bindings
Full width
Lines