Write a Python function to remove a specific element from a list.
list = [10,20,30,40]
def remove_element(list, element):
    for i in range(len(list)):
        if list[i] == element:
            del list[i]
            break
    return list

list = remove_element(list,40)