Input a list of numbers and find the smallest and largest number from the list Python Program

 

#create empty list 

mylist = []

number = int(input('How many elements to put in List: '))

for n in range(number):

    element = int(input('Enter element '))

    mylist.append(element)

print("Maximum element in the list is :", max(mylist))

print("Minimum element in the list is :", min(mylist))

Output:

 

How many elements to put in List: 5
Enter element 34
Enter element 23
Enter element 55
Enter element 11
Enter element 99
('Maximum element in the list is :', 99)
('Minimum element in the list is :', 11)
>>>

 

You may also Check :

Copywrite © 2020-2024, CBSE Python,
All Rights Reserved