homework_05/19_teodor_dishanski/decrypt.py
def decrypt_single_char(char, key):
    """Decrypt a single char with a given key."""
    assert isinstance(char, str)
    assert isinstance(key, int)

    upper_a_integer = ord('A')
    upper_z_integer = ord('Z')
    lower_a_integer = ord('a')
    lower_z_integer = ord('z')

    char_integer = ord(char)
    result = char_integer
    difference = (upper_z_integer - upper_a_integer) + 1

    if upper_a_integer <= char_integer <= upper_z_integer:
        result -= key
        if not upper_a_integer <= result <= upper_z_integer:
            result += difference
    elif lower_a_integer <= char_integer <= lower_z_integer:
        result -= key
        if not lower_a_integer <= result <= lower_z_integer:
            result += difference

    return chr(result)
Decrypt a single char with a given key.
Decrypt a single char with a given key.
Decrypt a single char with a given key .
def decrypt_single_char(char, key):
    assert isinstance(char, str)
    assert isinstance(key, int)
    upper_a_integer = ord('A')
    upper_z_integer = ord('Z')
    lower_a_integer = ord('a')
    lower_z_integer = ord('z')
    char_integer = ord(char)
    result = char_integer
    difference = (upper_z_integer - upper_a_integer) + 1
    if upper_a_integer <= char_integer <= upper_z_integer:
        result -= key
        if not upper_a_integer <= result <= upper_z_integer:
            result += difference
    elif lower_a_integer <= char_integer <= lower_z_integer:
        result -= key
        if not lower_a_integer <= result <= lower_z_integer:
            result += difference
    return chr(result)
def decrypt_single_char ( char , key ) : assert isinstance ( char , str ) assert isinstance ( key , int ) upper_a_integer = ord ( 'A' ) upper_z_integer = ord ( 'Z' ) lower_a_integer = ord ( 'a' ) lower_z_integer = ord ( 'z' ) char_integer = ord ( char ) result = char_integer difference = ( upper_z_integer - upper_a_integer ) + 1 if upper_a_integer <= char_integer <= upper_z_integer : result -= key if not upper_a_integer <= result <= upper_z_integer : result += difference elif lower_a_integer <= char_integer <= lower_z_integer : result -= key if not lower_a_integer <= result <= lower_z_integer : result += difference return chr ( result )
Decrypt a single char with a given key.
Decrypt a single char with a given key .
"""Decrypt a single char with a given key."""
char
key