{"id":3475,"date":"2022-12-01T18:54:09","date_gmt":"2022-12-01T18:54:09","guid":{"rendered":"https:\/\/gyanipandit.com\/programming\/?p=3475"},"modified":"2022-12-01T18:54:10","modified_gmt":"2022-12-01T18:54:10","slug":"python-dictionary-keys","status":"publish","type":"post","link":"https:\/\/gyanipandit.com\/programming\/python-dictionary-keys\/","title":{"rendered":"Python Dictionary keys() Method With Examples"},"content":{"rendered":"\n<p class=\"has-text-align-center\">Python Dictionary keys<\/p>\n\n\n\n<p>Now, we are going to have a look at the keys method. The keys method is going to give us a view object of the keys of the dictionary. The object contains the keys of the dictionary. Let\u2019s have a look at a sample program, which would help us better understand the keys method, and also help us visualize the output.<\/p>\n\n\n<h2 style=\"text-align: center;\">Python Dictionary keys() Method<\/h2>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"637\" height=\"177\" src=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/10\/THE-keys-METHOD.jpg\" alt=\"\" class=\"wp-image-3476\" srcset=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/10\/THE-keys-METHOD.jpg 637w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/10\/THE-keys-METHOD-300x83.jpg 300w\" sizes=\"auto, (max-width: 637px) 100vw, 637px\" \/><\/figure>\n<\/div>\n\n\n<p>As you can see, in the program, we are having a dictionary, and then we have called the keys method here. I have directly printed the output over here since we are more interested in the output right now.<\/p>\n\n\n\n<p>As an output, we get a view object, which contains all the keys of the dictionary, as a list. The output looks something like this &#8211;<\/p>\n\n\n\n<p class=\"has-white-color has-black-background-color has-text-color has-background\">dict_keys([&#8216;one&#8217;, &#8216;two&#8217;, &#8216;three&#8217;])<\/p>\n\n\n\n<p>As you can see in the output, we got the object with the keys for the given dictionary. So, we can make use of the keys method from the dictionary, as and when required.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python Dictionary keys Now, we are going to have a look at the keys method. The keys method is going to give us a view object of the keys of the dictionary. The object contains the keys of the dictionary. Let\u2019s have a look at a sample program, which would help us better understand the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[26,27],"class_list":{"0":"post-3475","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-python-tutorial","7":"tag-python","8":"tag-python-tutorial"},"_links":{"self":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/3475","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/comments?post=3475"}],"version-history":[{"count":2,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/3475\/revisions"}],"predecessor-version":[{"id":4153,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/3475\/revisions\/4153"}],"wp:attachment":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/media?parent=3475"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/categories?post=3475"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/tags?post=3475"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}