Kinston AG
0
Q:

python how to find the highest even in a list

# Python program to find largest 
# number in a list 
  
# creating empty list 
list1 = [] 
  
# asking number of elements to put in list 
num = int(input("Enter number of elements in list: ")) 
  
# iterating till num to append elements in list 
for i in range(1, num + 1): 
    ele = int(input("Enter elements: ")) 
    list1.append(ele) 
      
# print maximum element 
print("Largest element is:", max(list1)) 
3
def highest_even(li):
  evens = []
  for item in li:
    if item % 2 == 0:
      evens.append(item)
  return max(evens)

print(highest_even([10,2,3,4,8,11]))


# Building a function to find the highest even number in a list
0

New to Communities?

Join the community