Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(2)  |  Call(2)  |  Derive(0)  |  Import(0)
adds 'spam' to a list `l`

        def add_spam(l):
    "adds 'spam' to a list `l`"
    # you'll have to write code here
    return l

src/p/y/python-fundamentals-HEAD/challenges/05-Containers/test_A_lists.py   python-fundamentals(Download)
def test_spam(capsys):
    import A_lists as A
    empty_list = []
    result = A.add_spam(empty_list)
    test_list = ['here', 'is', 22, 'a', 'list']
    old_length = len(test_list)
    result = A.add_spam(test_list)
    assert len(result) == old_length+1, "add_spam() does not add an item"
    assert result[-1] == 'spam', "add_spam() does not add 'spam' to the end"