62. Problem to find maximum and minimum from the list.

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
  1. Take a heterogenous list as input.
  2. First check the element from the list is an integer or not using isinstance.
  3. If it is an integer then find the maximum and minimum from them using min() and max().
  4. 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

Character to Uppercase and lowercase

Sort a given list by the sum of sublists

Leave a Comment