So I am relatively new to python, not sure what is wrong here? I am sure it is a basic thing that I am missing but not sure what it could be, below is the code to find a matching target to any of the numbers in the list, which should work according to me but doesn't.
def abc(target,list1):
    for a in list1:
        if a == target:
            return a
        else:
            return 0
def main():
    target = input("enter target")
    list1 = []
    n = int(input("Enter number of elements : ")) 
    for i in range(0, n): 
        ele = input() 
    list1.append(ele)
g = abc(target,list1)
print(g)
if __name__== '__main__':
    main()
Below is the output which obviously returns 0 as the code does not work:
Enter target7
Enter number of elements : 4
5
6
7
8
0
should it not return 7 as the value in the list matches the target
 
     
    