In this Python list program, we will take a heterogenous list as input and find the maximum and minimum values from it with the help of the below-given steps.
Maximum and minimum from the list:
Steps to solve the program
- Take a heterogenous list as input.
- First check the element from the list is an integer or not using isinstance.
- If it is an integer then find the maximum and minimum from them using min() and max().
- Print the output to see the result.
#Input list
list1 = ["Sqa", 6, 5, 2, "Tools"]
#Finding min and max
max_ = max(value for value in list1 if isinstance(value, int))
min_ = min(value for value in list1 if isinstance(value, int))
#Printing output
print("Maximun: ", max_)
print("Minimun: ", min_)
Output :
Maximun: 6
Minimun: 2
Related Articles
Python program to sort a given list in ascending order according to the sum of its sublist.
Python program to extract the specified sizes of strings from a given list of string values.
Python program to find the difference between consecutive numbers in a given list.
Python program to calculate the average of the given list.
Python program to count integers in a given mixed list.
Python program to access multiple elements of the specified index from a given list.