def get_inverse_dict():
    """
    returns a dictionary which maps a -> z, b->y ... z->a
    Hint:
    1. see the constants in the string module, and the zip builtin function.
    2. google lookup extended slicing notation to create a z..a string from a..z string
    In shell: help(zip) and experiment using zip in shell
    In shell: import string to use the string.<> constants. we will learn about import later on.
    """
    return None

def texst_get_inverse_dict():
    result = get_inverse_dict()
    expected = 122
    for c in string.ascii_lowercase:
        assert ord(result[c]) == expected
        expected -= 1

i'm unable to understand what these functions are doing i need to insert piece of code to make that code work

Edited 2 Years Ago by pritaeas: Moved to python

The function get_inverse_dict() currently returns None. After you insert your code, it is supposed to return the dictionary

{'a': 'z', 'c': 'x', 'b': 'y', 'e': 'v', 'd': 'w', 'g': 't', 'f': 'u', 'i': 'r', 'h': 's', 'k': 'p', 'j': 'q', 'm': 'n', 'l': 'o', 'o': 'l', 'n': 'm', 'q': 'j', 'p': 'k', 's': 'h', 'r': 'i', 'u': 'f', 't': 'g', 'w': 'd', 'v': 'e', 'y': 'b', 'x': 'c', 'z': 'a'}

but you don't need to write the whole dictionary. Instead, follow the hints.

The function test_get_inverse_dict() executes without error if get_inverse_dict() returns the expected result. It is here to evaluate your code automatically. You don't need to understand how it works. Actually, a more complete version would be

def test_get_inverse_dict():
    result = get_inverse_dict()
    expected = 122
    for c in string.ascii_lowercase:
        assert ord(result[c]) == expected
        expected -= 1
    assert len(result) == 26

Edited 2 Years Ago by Gribouillis

Comments
thanks a lot i got it
This question has already been answered. Start a new discussion instead.