KnowledgeBoat Logo
|

Informatics Practices

Assertion (A): The popitem() method can be used to delete elements from a dictionary.

Reasoning (R): The popitem() method deletes the last inserted key-value pair and returns the value of deleted element.

  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

Both A and R are true and R is the correct explanation of A.

Explanation
The popitem() method in Python is used to delete elements from a dictionary. It returns and removes the last inserted key-value pair from the dictionary.

Answered By

3 Likes


Related Questions