Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Atbash Cipher by hkgok1
def atbash(plaintext: str) -> str:
# your code here
t = 'abcdefghijklmnopqrstuvwxyz'
t1 = t[::-1]
#print(t,t1)
def tran(i):
if i in t:
return t1[t.find(i)]
elif i.isupper() and i in t.upper():
return t1.upper()[t.upper().find(i)]
else:
return i
return ''.join(list(map(tran,plaintext)))
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!")
June 6, 2022