def num_of_nonzero_elements(my_vector):
    """Returns the number of non-zero elements in a vector"""
    counter = 0
    for element in my_vector:
        if element != 0:
            counter += 1
    return counter