Task: Generate a correct python program to fulfill the following purpose:
input: Count the occurrence of an element x in a list y.
output: def count_x(x, y):
    count = 0
    for i in range(y):
        if i == x:
            count += 1
    return count