Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
simple loop solution in Clear category for Atbash Cipher by Nocturne13
from string import ascii_letters
def atbash(plaintext: str) -> str:
# your code here
alphabet = ascii_letters
upper_letters = alphabet[26:]
lower_letters = alphabet[:26]
ans = ""
for i in plaintext:
if i.islower():
ans += lower_letters[25 - lower_letters.index(i)]
elif i.isupper():
ans += upper_letters[25 - upper_letters.index(i)]
else:
ans += i
return ans
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!")
July 3, 2023
Comments: