Can you design an algorithm in Python for finding the largest element in a list?
[2, 4, 9, 1, 8]
def max_element(lst):
    max_element = lst[0]
    for element in lst:
        if element > max_element:
            max_element = element
    return max_element