Search your topic here

Python Program to find the maximum from a list of numbers

To write a Python Program to find the maximum from a list of numbers. 

# creating empty list
listOfNumbers = [] 
  
# 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: ")) 
    listOfNumbers.append(ele) 
      
# print maximum element 
print("Largest element is:", max(listOfNumbers)) 


OUTPUT:

Enter number of elements in list: 4
Enter elements: 5
Enter elements: 6
Enter elements: 1
Enter elements: 9
Largest element is: 9

LEAVE A REPLY