Question

    What is the purpose of the keys() method in a

    dictionary?
    A To get the values of a dictionary Correct Answer Incorrect Answer
    B To get the keys of a dictionary Correct Answer Incorrect Answer
    C To add a new key-value pair to a dictionary Correct Answer Incorrect Answer
    D To remove a key-value pair from a dictionary Correct Answer Incorrect Answer
    E To sort a dictionary Correct Answer Incorrect Answer

    Solution

    Explanation: The keys() method returns a view object that displays a list of all the keys in a dictionary.

    Practice Next