Solution 1

def search_for_string(a_list, search_term):
    for item in a_list:
        if item == search_term:
            return 'string found!'
    return 'string not found'

Solution 2

def search_for_string(a_list, search_term):
    for item in a_list:
        if item == search_term:
            break
    else:
        return 'string not found'
    return 'string found!'

Search for string

Define a function search_for_string that receives a list and a search term.
Use a loop to go through the list and see if the string is there. If it is,
return 'string found!'. If not, return 'string not found'

Examples:

>>> search_for_string(['santiago', 'santi', 'santa'], 'santa')
'string found!''
>>> search_for_string(['a', 'b', 'c'], 'd')
'string not found'
>>> search_for_string([], 'a')
'string not found'

Test Cases

test empty list - Run Test

def test_empty_list():
    assert search_for_string([], 'a'), 'string not found'

test string present - Run Test

def test_string_present():
    assert search_for_string(['a', 'b', 'c'], 'd') == 'string not found'

test string in list - Run Test

def test_string_in_list():
    assert search_for_string(['santi', 'santa'], 'santa') == 'string found!'
def search_for_string(a_list, search_term): pass