In this python dictionary program, we will check whether a dictionary is empty or not.
Steps to solve the program
- Take a dictionary as input.
- Use an if-else statement with the len() function to check whether a dictionary is empty or not.
- Use logic to print the output.
dict1 = {}
if len(dict1) > 0:
print("Dictionary is not empty")
else:
print("Dictionary is empty")
Output :
Dictionary is empty