# Split the binary string into 5‑bit chunks result = [] for i in range(0, len(binary_string), 5): chunk = binary_string[i:i+5] if chunk in decode_map: result.append(decode_map[chunk]) return ''.join(result)
def decode(text): """ Decodes the text by shifting every letter 5 spots backward. """ decoded_message = ""
If your rules only apply to lowercase letters, a user entering capital letters might bypass your encoder. Use .toLowerCase() (JS) or .lower() (Python) to safely check character types.
def decode(binary_str): result = [] for i in range(0, len(binary_str), 5): chunk = binary_str[i:i+5] if chunk in decoding_table: result.append(decoding_table[chunk]) return ''.join(result)
To complete this lab successfully, you must master three core concepts:
: Isolating characters and determining how to alter them.
ord(char) gets the integer code point of the character, adds 1 to it, and chr() converts that new integer back into a character. Tips for Passing the CodeHS Autograder
If you want to minimize the total number of bits, assign shorter binary codes to commonly used letters (like E, T, A) and longer codes to less frequent ones (like Z, Q, X). This is the principle behind .
Double-check that all 26 letters (A-Z) and the space are included in your mapping. Check for "I" and "E":
: Ensure you manually add every letter from A to Z and the Space .