67. Problem to count integers in a given mixed list.

In this Python list program, we will take a user input as a list and count integers in a given mixed list with the help of the below-given steps.

Count integers in a list:

Steps to solve the program
  1. Take a list of mixed elements as input.
  2. Create a count variable to count integers in the given list.
  3. User for loop to iterate over each element of the list.
  4. Using isinstance() check whether the element is an integer or not.
  5. Print the final output to see the result.
				
					#Input list
list1 =["Hello", 45, "sqa",  23, 5, "Tools", 20]

#Crreating count variable
count = 0

for value in list1:
    if isinstance(value, int):
        count += 1

#Printing output        
print("Total number od integers: ",count)
				
			

Output :

				
					Total number of integers:  4
				
			

Related Articles

Calculate the average of the list

Access multiple elements of the specified index

Leave a Comment