+ 1
What is "keys" function in Python?
Like 👇 for i in range.keys():
4 Réponses
+ 3
Keys and values are part of dictionary. Go through this https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2450/
first for knowledge of keys and values in a dictionary
+ 3
Refer this for more details
https://code.sololearn.com/cQIq0SGZNO5S/?ref=app
+ 1
AKSHAY thank you! 😀👍
+ 1
<dict>.keys() creates a list-like object containing all the dictionary keys as items.
That might not be anything new since list(<dict>) gives a similar result: a list object containing all the dictionary keys as items.
What's special about dict_keys object is that it is interactive with the original dictionary: when an item gets removed from the dictionary the corresponding key will get removed from the dict-keys object.
There are also:
<dict>.values which does same for the dictionary items.
<dict>.items which stores the dictionary key: value pairs as (key, value).