jeudi 23 janvier 2020

The highest even number in a list

I want to find the highest even number in a list. The code I have used is able to do so successfully, but I don't know why my code is running right.

Please find my code below:

def highest_even(*list):
  for numbers in list:
    if numbers % 2 == 0:
      c= numbers
  print(c)

highest_even(1,2,3,4,5,6,7,8,9,10,11,12,111,222,444,555)

Even though I have only validated the even numbers, the output I am having is only the highest even number. Why is it so? Please help




Aucun commentaire:

Enregistrer un commentaire