Exemple #1
0
def replace(storage, cmd):
    #input: dict storage, string cmd
    #spec: replaces the value of transaction in day day with type tr_type and description description with value value
    day = int(cmd[1])
    value = int(cmd[5])
    tr_type = cmd[2]
    description = cmd[3]
    for i in range(len(get_day(storage, day))):
        if (get_descr(storage, day, i) == description):
            if (get_type(storage, day, i) == tr_type):
                set_value(storage, day, i, value)
Exemple #2
0
def write(storage, i, j):
    #input: dict storage, integer index
    #output: string string containing the elements of the list(index key) from the storage all put together
    string = str(get_value(storage, i, j)) + " "
    string += get_type(storage, i, j) + " " + get_descr(storage, i, j)
    return string
def test_get_descr():
    storage = {23: [[100, "out", "pizza"], [1000, "in", "salary"]]}
    assert get_descr(storage, 23, 0) == "pizza", 'should get "pizza"'
    assert get_descr(storage, 23, 1) == "salary", 'should get "salary"'