+ 1

What is "keys" function in Python?

Like 👇 for i in range.keys():

9th Aug 2020, 7:26 AM
Givantaro Coding
Givantaro Coding - avatar
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
9th Aug 2020, 7:29 AM
AKSHAY🇮🇳
AKSHAY🇮🇳 - avatar
9th Aug 2020, 7:31 AM
AKSHAY🇮🇳
AKSHAY🇮🇳 - avatar
+ 1
AKSHAY thank you! 😀👍
9th Aug 2020, 7:30 AM
Givantaro Coding
Givantaro Coding - avatar
+ 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).
9th Aug 2020, 12:55 PM
Seb TheS
Seb TheS - avatar