In this Python list program, we will take a user input as a list and count empty dictionaries from the given list with the help of the below-given steps.
Count empty dictionaries in a list:
Steps to solve the program
- Take user input as list containing dictionaries, lists, and tuples.
- Create an empty list.
- Use for loop to iterate over the given list.
- Use isinstance function to check whether the element in the list is a dictionary or not if yes and that dictionary is empty add that dictionary to the empty list.
- Count the number of empty dictionaries.
- Print the result to see the output.
Output :
Related Articles
Python program to remove consecutive duplicates of given lists.
Python program to pack consecutive duplicates of given list elements into sublists.
Python program to insert items at a specific position in the list.
Python program to select random numbers from the list.
Python program to create a 3*3 grid with numbers.