clear() - Removes all the elements from the dictionary

Removes all elements from the dictionary.

Example

Python
products = {
    'toothbrush': 2.50, 
    'tomato soup': 1.99
}

print(f'Number of products: {len(products)}')
products.clear()
print(f'Number of products after clear: {len(products)}')

Output

Number of products: 2
Number of products after clear: 0