Informatics Practices

Assertion (A): clear() method removes all elements from the dictionary.

Reasoning (R): len() function cannot be used to find the length of a dictionary.

  1. Both A and R are true and R is the correct explanation of A.
  2. Both A and R are true but R is not the correct explanation of A.
  3. A is true but R is false.
  4. A is false but R is true.

Python Dictionaries

3 Likes

Answer

A is true but R is false.

Explanation
The clear() method removes all items from the particular dictionary and returns an empty dictionary. The len() method returns the length of key-value pairs in the given dictionary.

Answered By

2 Likes


Related Questions