mardi 2 août 2016

The ouput of the code is 3. Can someone explain how?

def my_fun(x):     
    z = 0     
    for item in x:         
       m = x.count(item)         
       if m > z:             
           z = m     
       return z  

y = ["cat", 4, "dog" , "cat" , 2, "cat", 2] 
print (my_fun(y))

The ouput of the code is 3. Can someone explain how?

Aucun commentaire:

Enregistrer un commentaire