count number of even and odd numbers from a list using function in Python

# to count number of even and odd

def count(lst):  # function declaration as "count" with func argument as "lst"

    even = 0 # counter to count even no
    odd = 0 # counter to odd number

    for i in lst:   #loop to iterate through list 

        if i % 2 == 0:   # understand the logic on your own
            even += 1
        else:
            odd += 1
    return even,odd

lst=[2,4,5,6,7,8,93,5] #list declaration

even,odd = count(lst)

print(even) # printing function
print(odd)

output 






Thankyou 
comment down if any problem , or  any question

Comments