Q. How is pop() different from popitem()?


Answer =

The difference between pop() and popitem() is that the pop() can delete an item with a chosen key while popitem() will remove only the last entered item from the dictionary. Also, you can specify the return value/message in pop() if the given key is not found in the dictionary, but you cannot frame any such message in popitem( ) while deleting from an empty dictionary; it will raise an error then.

8 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post