def evenchecker(lst):
for number in lst:
return number%2==0
else:
pass
I am trying to create a function that checks for an even number in the list or any iterable item for that matter. When I keep the first number as an even number it works but when I keep the first number as odd it falls apart, it just returns false and does not report true for the further even numbers.
Can somebody please explain why is this happening, I am an absolute beginner in programming and learning from a Udemy course. I did find a workaround for this,
def evenchecker(lst):
for number in lst:
if number%2==0:
return "The list has an even number"
else:
pass
this checks on till the last number.