Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Translating upper and lowers solution in Clear category for Atbash Cipher by dig
def atbash(plaintext: str) -> str:
uppers='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
lowers='abcdefghijklmnopqrstuvwxyz'
letters=uppers+lowers
letters2=uppers[::-1]+lowers[::-1]
mytable = plaintext.maketrans(letters, letters2)
return plaintext.translate(mytable)
if __name__ == "__main__":
print("Example:\nplaintext: testing")
print(atbash("testing"))
# These "asserts" are used for self-checking and not for an auto-testing
assert atbash("testing") == "gvhgrmt"
assert atbash("attack at dawn") == "zggzxp zg wzdm"
assert atbash("Hello, world!") == "Svool, dliow!"
print("Coding complete? Click 'Check' to earn cool rewards!")
March 7, 2023