In this program, we will take a user input as a list and find the minimum and maximum elements from it with the help of the below-given steps.
Minimum and maximum element in list:
Method 1 : Sorting and indexing
Steps to solve the program
- Take a list as input.
- Sort the list using Sort().
- Print the maximum value i.e. element with -1 index.
- Print the minimum value i.e. element with 0 index.
Output :
Minimum and maximum element in list:
Method 2 : Using in-built function
Steps to solve the program
- Take a list as input.
- Print the maximum value using max().
- Print the minimum value using min().
Output :
Related Articles
Python program to differentiate even and odd elements from the given list.
Python program to remove all duplicate elements from the list.
Python program to print a combination of 2 elements from the list whose sum is 10.
Python program to print squares of all even numbers in a list.
Python program to get common elements from two lists.