MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / atbash_slow

Function atbash_slow

ciphers/atbash.py:6–23  ·  view source on GitHub ↗

>>> atbash_slow("ABCDEFG") 'ZYXWVUT' >>> atbash_slow("aW;;123BX") 'zD;;123YC'

(sequence: str)

Source from the content-addressed store, hash-verified

4
5
6def atbash_slow(sequence: str) -> str:
7 """
8 >>> atbash_slow("ABCDEFG")
9 'ZYXWVUT'
10
11 >>> atbash_slow("aW;;123BX")
12 'zD;;123YC'
13 """
14 output = ""
15 for i in sequence:
16 extract = ord(i)
17 if 65 <= extract <= 90:
18 output += chr(155 - extract)
19 elif 97 <= extract <= 122:
20 output += chr(219 - extract)
21 else:
22 output += i
23 return output
24
25
26def atbash(sequence: str) -> str:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected