{"id":11758,"date":"2024-10-21T12:02:55","date_gmt":"2024-10-21T12:02:55","guid":{"rendered":"http:\/\/www.wscubetech.com\/blog\/?p=11758"},"modified":"2026-02-14T07:16:07","modified_gmt":"2026-02-14T07:16:07","slug":"iterate-through-dictionary-python","status":"publish","type":"post","link":"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/","title":{"rendered":"How to Iterate Through a Dictionary in Python? (With Examples)"},"content":{"rendered":"\n<p>In <a href=\"https:\/\/www.wscubetech.com\/resources\/python\/\" target=\"_blank\" rel=\"noreferrer noopener\">Python<\/a>, iterating over a dictionary is a crucial skill for developers to be able to access and manipulate key-value pairs efficiently. It allows them to perform different operations, including updating information, extracting values, and applying a particular logic to every key-value pair.&nbsp;<\/p>\n\n\n\n<p>Moreover, developers must know how to iterate over a <a href=\"https:\/\/www.wscubetech.com\/resources\/python\/dictionary\" target=\"_blank\" rel=\"noreferrer noopener\">dictionary in Python<\/a> to handle and process data while interacting effectively with the contents of a dictionary. This blog discusses different ways to iterate through a dictionary in Python, explaining each method with an example.&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Python Dictionaries<\/h2>\n\n\n\n<p>Dictionaries are useful data structures in Python that store items in key-value pairs. Keys on dictionaries are hashable, so their values can\u2019t be changed. Also, there can\u2019t be duplicate keys in a dictionary. We can access values stored in a dictionary using keys. Many aspects of Python are built around dictionaries. Classes, modules, objects, locals(), and globals() show how deeply dictionaries are wired into the implementation of Python.&nbsp;<\/p>\n\n\n\n<p>The keys in a dictionary are like a set. They are hashable (so we can\u2019t use mutable objects as keys) and unique objects. Values in a dictionary can be of any data type, be it hashable or non-hashable.&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Key points to remember about Python dictionaries<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Dictionaries store items in key-value pairs. They map keys to values and store them in a collection.<\/li>\n\n\n\n<li>Dictionaries are indexed by keys, so we can access values stored in them using their associated keys.<\/li>\n\n\n\n<li>Keys in dictionaries are hashable, so they must have a hash value that can never change during a key\u2019s lifetime.&nbsp;<\/li>\n<\/ul>\n\n\n\n<p><strong>Also read: <\/strong><a href=\"https:\/\/www.wscubetech.com\/blog\/python-books\/\" target=\"_blank\" rel=\"noreferrer noopener\">10+ Best Python Books For Beginners and Experts<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Iterate Over a Dictionary in Python<\/h2>\n\n\n\n<p>Iterating through a dictionary refers to going through each key-value pair one by one, accessing a dictionary, and traversing every key-value present. It is crucial to use a Python dictionary properly. In Python, iterating over a dictionary is possible through various ways that we have discussed below:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Iterate through Python dictionary using build.keys()<\/li>\n\n\n\n<li>Iterate key-value pair using items()<\/li>\n\n\n\n<li>Iterate through all values using .values()<\/li>\n\n\n\n<li>Looping through a dictionary using for loop<\/li>\n\n\n\n<li>Access a key in Python using zip()<\/li>\n\n\n\n<li>Access key using map() and dict.get<\/li>\n\n\n\n<li>Access key Using Unpacking of dictionary<\/li>\n<\/ol>\n\n\n\n    <!-- LOTTIE SCRIPT -->\n    <script src=\"https:\/\/unpkg.com\/@lottiefiles\/lottie-player@latest\/dist\/lottie-player.js\"><\/script>\n\n    <section class=\"wscube-courses\">\n        <div class=\"container\">\n            <h3 class=\"mb-4\">Recommended Professional <\/br> Certificates<\/h3>\n\n            <div class=\"owl-carousel courseOwl\">\n\n                \n                    \n                    <div class=\"course-card card-r rounded-4\">\n\n                        <!-- \u2705 SINGLE MEDIA DIV (FIXED) -->\n                        <div class=\"course-media\"\n                             data-lottie=\"https:\/\/www.wscubetech.com\/uploads\/images\/courses\/json-images\/data-analyst.json\"\n                             data-fallback=\"https:\/\/www.wscubetech.com\/blog\/wp-content\/themes\/newwscube\/assets\/imges\/Image.png\">\n                        <\/div>\n\n                        <div class=\"card-body\">\n                            <h5>Data Analytics Mentorship Program<\/h5>\n\n                            <p class=\"rating\">\n                                4.9 \u2605\u2605\u2605\u2605\u2605\n                                (1032)\n                            <\/p>\n\n                            <ul class=\"course-meta\">\n                                <li>\ud83d\udc64 3785 Learners<\/li>\n                                <li>\u23f1 18 Weeks<\/li>\n                            <\/ul>\n\n                            <div class=\"mt-3\">\n                                                                    <a href=\"https:\/\/www.wscubetech.com\/data-analytics-course?utm_source=WsBlog&#038;utm_medium=blog_course_slider&#038;utm_campaign=SEO\"\n                                       target=\"_blank\"\n                                       class=\"btn view-btn btn-sm\">\n                                        View Brochure\n                                    <\/a>\n                                \n                                <a target=\"_blank\"\n                                   href=\"https:\/\/www.wscubetech.com\/data-analytics-course?utm_source=WsBlog&#038;utm_medium=blog_course_slider&#038;utm_campaign=SEO\"\n                                   class=\"btn btn-outline-secondary btn-sm\">\n                                    Learn More\n                                <\/a>\n                            <\/div>\n                        <\/div>\n                    <\/div>\n\n                \n                    \n                    <div class=\"course-card card-r rounded-4\">\n\n                        <!-- \u2705 SINGLE MEDIA DIV (FIXED) -->\n                        <div class=\"course-media\"\n                             data-lottie=\"\"\n                             data-fallback=\"https:\/\/deen3evddmddt.cloudfront.net\/uploads\/courses-images\/data-science-thumbnail.webp\">\n                        <\/div>\n\n                        <div class=\"card-body\">\n                            <h5>Data Science &amp; AI Mentorship Program  <\/h5>\n\n                            <p class=\"rating\">\n                                4.5 \u2605\u2605\u2605\u2605\u2605\n                                (1254)\n                            <\/p>\n\n                            <ul class=\"course-meta\">\n                                <li>\ud83d\udc64 3785 Learners<\/li>\n                                <li>\u23f1 20 Weeks<\/li>\n                            <\/ul>\n\n                            <div class=\"mt-3\">\n                                                                    <a href=\"https:\/\/www.wscubetech.com\/data-science-course?utm_source=WsBlog&#038;utm_medium=blog_course_slider&#038;utm_campaign=SEO\"\n                                       target=\"_blank\"\n                                       class=\"btn view-btn btn-sm\">\n                                        View Brochure\n                                    <\/a>\n                                \n                                <a target=\"_blank\"\n                                   href=\"https:\/\/www.wscubetech.com\/data-science-course?utm_source=WsBlog&#038;utm_medium=blog_course_slider&#038;utm_campaign=SEO\"\n                                   class=\"btn btn-outline-secondary btn-sm\">\n                                    Learn More\n                                <\/a>\n                            <\/div>\n                        <\/div>\n                    <\/div>\n\n                \n            <\/div>\n        <\/div>\n    <\/section>\n\n    \n\n\n\n<h3 class=\"wp-block-heading\">1. <strong>Iterate through Python dictionary using build.keys()<\/strong><\/h3>\n\n\n\n<p>In Python, we can use the built-in keys() method to access the keys of a dictionary. It is a simple method to iterate over and manipulate the structure of a dictionary and returns a view object displaying a list of all the keys in the dictionary. The keys() method allows us to efficiently traverse the keys of a dictionary, making it suitable for tasks that involve working with the keys themselves.&nbsp;<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Example&nbsp;<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>my_dict = {'name': 'Harshit', 'age': 25, 'city': 'Jodhpur'}\nfor key in my_dict.keys():\n    print(key)\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Output<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>name\nage\ncity<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. <strong>Iterate key-value pair using items()<\/strong><\/h3>\n\n\n\n<p>Using the built-in items() method in Python, we can access keys and items at the same time, so we can effectively manipulate the entire structure of the dictionary. This powerful tool allows us to iterate through key-value pairs and returns the view object containing a key-value pair as tuples.&nbsp;<\/p>\n\n\n\n<p>Using items() provides a concise way to navigate through the entire dictionary, extracting keys and values as needed. It is a useful method for tasks that require simultaneous access to both components of every key-value pair.&nbsp;<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Example<\/strong><strong>&nbsp;<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>my_dict = {'name': 'Harshit', 'age': 25, 'city': 'Jodhpur'}\nfor key, value in my_dict.items():\n    print(f\"{key}: {value}\")\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Output:<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>name: Harshit\nage: 25\ncity: Jodhpur\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. Iterate through all values using .values()<\/strong><\/h3>\n\n\n\n<p>The values() method is another straightforward way to efficiently iterate through all values of a dictionary in Python. Hence, it is useful for tasks that involve working with values directly instead of keys associated with them.&nbsp;<\/p>\n\n\n\n<p>It returns a view object with all the values present in the dictionary, so we can access and manipulate data without explicitly dealing with keys. The values() method provides the flexibility of manipulating a dictionary in Python. To use the values() method to iterate over all values of a dictionary, employ the for loop, accessing every value sequentially. You can process or display every individual value in the dictionary without explicitly referencing the associated keys.&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Example<\/strong><strong>&nbsp;<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>my_dict = {'name': 'Harshit', 'age': 25, 'city': 'Jodhpur'}\nfor value in my_dict.values():\n    print(value)<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Output<\/h4>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>Harshit\n25\nJodhpur<\/code><\/pre>\n\n\n\n<p class=\"has-white-color has-vivid-cyan-blue-background-color has-text-color has-background has-link-color wp-elements-bcaaed4e49a1ccf7890f6e0b701e6427\"><strong>Read More Python Guides<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\"><a href=\"https:\/\/www.wscubetech.com\/blog\/python-books\/\" target=\"_blank\" rel=\"noreferrer noopener\">Best Python Books<\/a><\/td><td class=\"has-text-align-center\" data-align=\"center\"><a href=\"https:\/\/www.wscubetech.com\/blog\/python-project-ideas\/\" target=\"_blank\" rel=\"noreferrer noopener\">Python Project Ideas<\/a><\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\"><a href=\"https:\/\/www.wscubetech.com\/blog\/python-developer-roadmap\/\" target=\"_blank\" rel=\"noreferrer noopener\">Python Developer Roadmap<\/a><\/td><td class=\"has-text-align-center\" data-align=\"center\"><a href=\"https:\/\/www.wscubetech.com\/blog\/python-course-duration-fees\/\" target=\"_blank\" rel=\"noreferrer noopener\">Python Course Details<\/a><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">4. <strong>Looping through a dictionary using for loop<\/strong><\/h3>\n\n\n\n<p>Using a for loop is also a fundamental and versatile way to iterate through a dictionary. This method allows us to easily access keys in a dictionary without using the keys() method and directly iterate over the dictionary using a for loop.&nbsp;<\/p>\n\n\n\n<p>The for loop iterates automatically over the keys, so we can access every key without explicitly needing the method call. We can manipulate data stored within efficiently and seamlessly. This is particularly useful for working with the keys of a dictionary.&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Example<\/strong><strong>&nbsp;<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>my_dict = {'name': 'Harshit', 'age': 25, 'city': 'Jodhpur'}\nfor key in my_dict:\n    print(key)<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Output:<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>name\nage\ncity<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">5. <strong>Access a key in Python using zip()<\/strong><\/h3>\n\n\n\n<p>The zip() function in Python allows us to access the keys of a dictionary by iterating over a tuple of keys and values of a dictionary. Using this method in conjunction with the keys of a dictionary, we can create pairs of keys and their corresponding values.&nbsp;<\/p>\n\n\n\n<p>We can iterate through keys without directly accessing the dictionary. Hence, it is useful when we work with key-value pairs as tuples. It improves the iterating flexibility through dictionary keys in an expressive and readable manner.&nbsp;<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Example<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>my_dict = {'name': 'Harshit', 'age': 25, 'city': 'Jodhpur'}\nkeys = list(my_dict.keys())\nvalues = list(my_dict.values())\nfor key, value in zip(keys, values):\n    print(f\"{key}: {value}\")<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Output:<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>name: Harshit\nage: 25\ncity: Jodhpur<\/code><\/pre>\n\n\n\n<p><strong>Also read:<\/strong> <a href=\"https:\/\/www.wscubetech.com\/blog\/python-project-ideas\/\" target=\"_blank\" rel=\"noreferrer noopener\">25+ Python Project Ideas (Beginners to Experienced)<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">6. <strong>Access key using map() and dict.get<\/strong><\/h3>\n\n\n\n<p>Python also offers the map() function with dict.get() to access keys in a dictionary. The combination of map() and dict.get() is a concise and efficient approach to applying a function to each key, returning a map object of corresponding values. It returns a new iterable containing the results.<\/p>\n\n\n\n<p>This method allows direct iteration over dictionary keys and efficiently obtains their values concisely. It improves the flexibility of working with dictionaries.&nbsp;<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Example&nbsp;<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>my_dict = {'name': 'Harshit', 'age': 25, 'city': 'Jodhpur'}\nkeys = my_dict.keys()\nvalues = map(my_dict.get, keys)\nfor value in values:\n    print(value)<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Output:<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>Harshit\n25\nJodhpur<\/code><\/pre>\n\n\n\n        <div class=\"container position-relative\">\n            <div class=\"row pb-4\">\n                <h2 style=\"font-size:32px\">Upcoming Masterclass<\/h2>\n                <p>Attend our live classes led by experienced and desiccated instructors of Wscube Tech.<\/p>\n            <\/div>\n            <div class=\"owl-carousel myOwl\">\n                <div class=\"item\">\n                    <a href=\"https:\/\/www.wscubetech.com\/events\/master-sql-for-data-business-analytics-with-ai-skills?utm_source=WsBlog&utm_medium=blog_master_class_slider&utm_campaign=SEO\" target=\"_blank\">\n                        <img decoding=\"async\" src=\"https:\/\/deen3evddmddt.cloudfront.net\/uploads\/master-class-media\/SQL for Data sdds.webp\" alt=\"Master SQL for Data\/Business Analytics with AI Skills\" \/>\n                    <\/a>\n                <\/div>\n            <\/div>\n        <\/div>\n\n\n\n<h3 class=\"wp-block-heading\">7. <strong>Access key using unpacking of dictionary<\/strong><\/h3>\n\n\n\n<p>Unpacking is a simple and efficient way to access and iterate through dictionary keys without calling any method explicitly. This process involves extracting keys directly from a dictionary and then working with each of them individually. Unpacking is a readable and concise method to access keys and can come in handy when we want a list of keys without any additional methods or <a href=\"https:\/\/www.wscubetech.com\/resources\/python\/functions\" target=\"_blank\" rel=\"noreferrer noopener\">functions<\/a>.&nbsp;<\/p>\n\n\n\n<p>When we work with <a href=\"https:\/\/www.wscubetech.com\/resources\/python\/dictionary\" target=\"_blank\" rel=\"noreferrer noopener\">Python dictionaries<\/a>, unpacking improves the code clarity and expressiveness. We use asterisk (*) to unpack the keys into a list or another iterable and access them through unpacking of a dictionary.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Example<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>my_dict = {'name': 'Harshit', 'age': 25, 'city': 'Jodhpur'}\nfor key in *my_dict,:\n    print(key)<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Output:<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>name\nage\ncity<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">FAQs &#8211; Iterating Over a Dictionary in Python<\/h2>\n\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1729510879093\"><strong class=\"schema-faq-question\">1. <strong>How to iterate through multiple dictionaries at one time?<\/strong><\/strong> <p class=\"schema-faq-answer\">In Python, collections and itertools standard-library modules offer the ChainMap class and chain() function, respectively, that we can use to combine multiple dictionaries and iterate through them. However, these tools have a few basic differences. In the case of duplicate keys in input dictionaries, ChainMap provides only access to the first instance of a key, whereas chain() allows access to all the instances of repeated keys.\u00a0<br\/><br\/>We can also use the unpacking operator (**) to combine multiple dictionaries and iterate through the resulting dictionary. When the input dictionaries have duplicate keys, only the last instance of the repeated key will prevail.\u00a0<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1729510922557\"><strong class=\"schema-faq-question\">2. <strong>How to iterate over key-value pairs in a dictionary?<\/strong><\/strong> <p class=\"schema-faq-answer\">We can iterate over an item of a dictionary using a for loop. This will return key-value pairs.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1729510941199\"><strong class=\"schema-faq-question\">3. <strong>How to iterate through a dictionary in a specific order?<\/strong><\/strong> <p class=\"schema-faq-answer\">We use the built-in sorted() function to iterate through a dictionary in a specific order. If fed with the result of .items(), the function will return a list of key-value tuples that we can traverse in a loop. We can also use the reversed() function to iterate through a dictionary in reverse order.\u00a0<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1729510949948\"><strong class=\"schema-faq-question\">4. <strong>How to iterate over a dictionary while changing its content?<\/strong><\/strong> <p class=\"schema-faq-answer\">To change or update the values of a dictionary, we can use a loop because dictionaries are mutable, so we can change their values easily. However, to remove key-value pairs from a dictionary while looping through it, use a copy for iteration and remove the values from the original dictionary. The copy() method allows you to create a shallow copy of a dictionary. The popitem() method is used with the while loop to remove consecutive items from a dictionary without making its copy.\u00a0<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1729510986416\"><strong class=\"schema-faq-question\">5. <strong>How to get an iterable of dictionary values?<\/strong><\/strong> <p class=\"schema-faq-answer\">We use the values() method in Python to get an iterable of values for a dictionary.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1729510993556\"><strong class=\"schema-faq-question\">6. <strong>How do we iterate over values in a dictionary?<\/strong><\/strong> <p class=\"schema-faq-answer\">We use a for loop to iterate over the values of a dictionary in Python<\/p> <\/div> <\/div>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.wscubetech.com\/data-analytics-course?utm_source=WsBlog&amp;utm_medium=BlogBanner&amp;utm_campaign=seo&amp;utm_page=\/iterate-through-dictionary-python\/\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1546\" height=\"421\" src=\"https:\/\/www.wscubetech.com\/blog\/wp-content\/uploads\/2023\/09\/da-course-1.webp\" alt=\"\" class=\"wp-image-12830\" srcset=\"https:\/\/www.wscubetech.com\/blog\/wp-content\/uploads\/2023\/09\/da-course-1.webp 1546w, https:\/\/www.wscubetech.com\/blog\/wp-content\/uploads\/2023\/09\/da-course-1-300x82.webp 300w, https:\/\/www.wscubetech.com\/blog\/wp-content\/uploads\/2023\/09\/da-course-1-1024x279.webp 1024w, https:\/\/www.wscubetech.com\/blog\/wp-content\/uploads\/2023\/09\/da-course-1-768x209.webp 768w, https:\/\/www.wscubetech.com\/blog\/wp-content\/uploads\/2023\/09\/da-course-1-1536x418.webp 1536w\" sizes=\"auto, (max-width: 1546px) 100vw, 1546px\" \/><\/a><\/figure>\n\n\n\n<p><strong>Conclusion<\/strong><\/p>\n\n\n\n<p>Knowing how to iterate through a dictionary in Python is crucial as it enables you to work with data seamlessly. Also, it is a vital skill if you want to access the keys and values of a dictionary. Hence, whether you are a beginner or an experienced Python programmer, learning how to iterate through a dictionary will make working with data hassle-free and efficient. You will have a powerful tool to manipulate and navigate information effectively in <a href=\"https:\/\/www.wscubetech.com\/resources\/python\/programs\" target=\"_blank\" rel=\"noreferrer noopener\">Python programs<\/a>.&nbsp;<\/p>\n\n\n\n<p>In this blog, we explored different methods to iterate over a dictionary, such as values(), keys(), items(), map(), zip(), loops, unpacking, etc. There are diverse ways to handle dictionaries, and you can pick the one that suits your goals and needs.&nbsp;<\/p>\n\n\n\n<p><strong>Start Learning With Our Free Tutorials<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\"><a href=\"https:\/\/www.wscubetech.com\/resources\/java\" target=\"_blank\" rel=\"noreferrer noopener\">Java Tutorial<\/a><\/td><td class=\"has-text-align-center\" data-align=\"center\"><a href=\"https:\/\/www.wscubetech.com\/resources\/javascript\" target=\"_blank\" rel=\"noreferrer noopener\">JavaScript Tutorial<\/a><\/td><td class=\"has-text-align-center\" data-align=\"center\"><a href=\"https:\/\/www.wscubetech.com\/resources\/dsa\" target=\"_blank\" rel=\"noreferrer noopener\">DSA Tutorial<\/a><\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\"><a href=\"https:\/\/www.wscubetech.com\/resources\/cpp\" target=\"_blank\" rel=\"noreferrer noopener\">C++ Tutorial<\/a><\/td><td class=\"has-text-align-center\" data-align=\"center\"><a href=\"https:\/\/www.wscubetech.com\/resources\/css\" target=\"_blank\" rel=\"noreferrer noopener\">CSS Tutorial<\/a><\/td><td class=\"has-text-align-center\" data-align=\"center\"><a href=\"https:\/\/www.wscubetech.com\/resources\/sql\" target=\"_blank\" rel=\"noreferrer noopener\">SQL Tutorial<\/a><\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>In Python, iterating over a dictionary is a crucial skill for developers to be able to access and manipulate key-value pairs efficiently. It allows them to perform different operations, including updating information, extracting values, and applying a particular logic to every key-value pair.&nbsp; Moreover, developers must know how to iterate over a dictionary in Python [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":11851,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[287,68],"tags":[],"class_list":["post-11758","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-data","category-web-development"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Iterate Through a Dictionary in Python? (With Examples)<\/title>\n<meta name=\"description\" content=\"Learn how to iterate through a dictionary in Python with easy examples. Discover different methods to access and manipulate dictionary elements. Read now!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Iterate Through a Dictionary in Python? (With Examples)\" \/>\n<meta property=\"og:description\" content=\"Learn how to iterate through a dictionary in Python with easy examples. Discover different methods to access and manipulate dictionary elements. Read now!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/\" \/>\n<meta property=\"og:site_name\" content=\"WsCube Tech Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/wscubetech.india\" \/>\n<meta property=\"article:published_time\" content=\"2024-10-21T12:02:55+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-02-14T07:16:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wscubetech.com\/blog\/wp-content\/uploads\/2024\/10\/iterating-over-a-dictionary-in-python.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"780\" \/>\n\t<meta property=\"og:image:height\" content=\"400\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Ashima Jain\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@wscube\" \/>\n<meta name=\"twitter:site\" content=\"@wscube\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ashima Jain\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/\",\"url\":\"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/\",\"name\":\"How to Iterate Through a Dictionary in Python? (With Examples)\",\"isPartOf\":{\"@id\":\"https:\/\/www.wscubetech.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.wscubetech.com\/blog\/wp-content\/uploads\/2024\/10\/iterating-over-a-dictionary-in-python.webp\",\"datePublished\":\"2024-10-21T12:02:55+00:00\",\"dateModified\":\"2026-02-14T07:16:07+00:00\",\"author\":{\"@id\":\"https:\/\/www.wscubetech.com\/blog\/#\/schema\/person\/6995f82316ae760c1856b1bff807a793\"},\"description\":\"Learn how to iterate through a dictionary in Python with easy examples. Discover different methods to access and manipulate dictionary elements. Read now!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#breadcrumb\"},\"mainEntity\":[{\"@id\":\"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510879093\"},{\"@id\":\"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510922557\"},{\"@id\":\"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510941199\"},{\"@id\":\"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510949948\"},{\"@id\":\"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510986416\"},{\"@id\":\"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510993556\"}],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#primaryimage\",\"url\":\"https:\/\/www.wscubetech.com\/blog\/wp-content\/uploads\/2024\/10\/iterating-over-a-dictionary-in-python.webp\",\"contentUrl\":\"https:\/\/www.wscubetech.com\/blog\/wp-content\/uploads\/2024\/10\/iterating-over-a-dictionary-in-python.webp\",\"width\":780,\"height\":400},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.wscubetech.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Iterate Through a Dictionary in Python? (With Examples)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wscubetech.com\/blog\/#website\",\"url\":\"https:\/\/www.wscubetech.com\/blog\/\",\"name\":\"WsCube Tech Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wscubetech.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wscubetech.com\/blog\/#\/schema\/person\/6995f82316ae760c1856b1bff807a793\",\"name\":\"Ashima Jain\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wscubetech.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/7660a6dae5a26ff506f0be04c3c35807480f565ca201c63311fd4bfa47ff02a0?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/7660a6dae5a26ff506f0be04c3c35807480f565ca201c63311fd4bfa47ff02a0?s=96&d=mm&r=g\",\"caption\":\"Ashima Jain\"},\"description\":\"Ashima Jain is a Content Editor and Strategist at WsCube Tech and has been in the content marketing industry for 6 years.\",\"url\":\"https:\/\/www.wscubetech.com\/blog\/author\/ashima\/\"},{\"@type\":\"Question\",\"@id\":\"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510879093\",\"position\":1,\"url\":\"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510879093\",\"name\":\"1. How to iterate through multiple dictionaries at one time?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"In Python, collections and itertools standard-library modules offer the ChainMap class and chain() function, respectively, that we can use to combine multiple dictionaries and iterate through them. However, these tools have a few basic differences. In the case of duplicate keys in input dictionaries, ChainMap provides only access to the first instance of a key, whereas chain() allows access to all the instances of repeated keys.\u00a0<br\/><br\/>We can also use the unpacking operator (**) to combine multiple dictionaries and iterate through the resulting dictionary. When the input dictionaries have duplicate keys, only the last instance of the repeated key will prevail.\u00a0\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510922557\",\"position\":2,\"url\":\"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510922557\",\"name\":\"2. How to iterate over key-value pairs in a dictionary?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"We can iterate over an item of a dictionary using a for loop. This will return key-value pairs.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510941199\",\"position\":3,\"url\":\"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510941199\",\"name\":\"3. How to iterate through a dictionary in a specific order?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"We use the built-in sorted() function to iterate through a dictionary in a specific order. If fed with the result of .items(), the function will return a list of key-value tuples that we can traverse in a loop. We can also use the reversed() function to iterate through a dictionary in reverse order.\u00a0\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510949948\",\"position\":4,\"url\":\"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510949948\",\"name\":\"4. How to iterate over a dictionary while changing its content?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"To change or update the values of a dictionary, we can use a loop because dictionaries are mutable, so we can change their values easily. However, to remove key-value pairs from a dictionary while looping through it, use a copy for iteration and remove the values from the original dictionary. The copy() method allows you to create a shallow copy of a dictionary. The popitem() method is used with the while loop to remove consecutive items from a dictionary without making its copy.\u00a0\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510986416\",\"position\":5,\"url\":\"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510986416\",\"name\":\"5. How to get an iterable of dictionary values?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"We use the values() method in Python to get an iterable of values for a dictionary.\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510993556\",\"position\":6,\"url\":\"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510993556\",\"name\":\"6. How do we iterate over values in a dictionary?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"We use a for loop to iterate over the values of a dictionary in Python\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Iterate Through a Dictionary in Python? (With Examples)","description":"Learn how to iterate through a dictionary in Python with easy examples. Discover different methods to access and manipulate dictionary elements. Read now!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/","og_locale":"en_US","og_type":"article","og_title":"How to Iterate Through a Dictionary in Python? (With Examples)","og_description":"Learn how to iterate through a dictionary in Python with easy examples. Discover different methods to access and manipulate dictionary elements. Read now!","og_url":"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/","og_site_name":"WsCube Tech Blog","article_publisher":"https:\/\/www.facebook.com\/wscubetech.india","article_published_time":"2024-10-21T12:02:55+00:00","article_modified_time":"2026-02-14T07:16:07+00:00","og_image":[{"width":780,"height":400,"url":"https:\/\/www.wscubetech.com\/blog\/wp-content\/uploads\/2024\/10\/iterating-over-a-dictionary-in-python.webp","type":"image\/webp"}],"author":"Ashima Jain","twitter_card":"summary_large_image","twitter_creator":"@wscube","twitter_site":"@wscube","twitter_misc":{"Written by":"Ashima Jain","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["WebPage","FAQPage"],"@id":"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/","url":"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/","name":"How to Iterate Through a Dictionary in Python? (With Examples)","isPartOf":{"@id":"https:\/\/www.wscubetech.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#primaryimage"},"image":{"@id":"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.wscubetech.com\/blog\/wp-content\/uploads\/2024\/10\/iterating-over-a-dictionary-in-python.webp","datePublished":"2024-10-21T12:02:55+00:00","dateModified":"2026-02-14T07:16:07+00:00","author":{"@id":"https:\/\/www.wscubetech.com\/blog\/#\/schema\/person\/6995f82316ae760c1856b1bff807a793"},"description":"Learn how to iterate through a dictionary in Python with easy examples. Discover different methods to access and manipulate dictionary elements. Read now!","breadcrumb":{"@id":"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#breadcrumb"},"mainEntity":[{"@id":"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510879093"},{"@id":"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510922557"},{"@id":"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510941199"},{"@id":"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510949948"},{"@id":"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510986416"},{"@id":"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510993556"}],"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#primaryimage","url":"https:\/\/www.wscubetech.com\/blog\/wp-content\/uploads\/2024\/10\/iterating-over-a-dictionary-in-python.webp","contentUrl":"https:\/\/www.wscubetech.com\/blog\/wp-content\/uploads\/2024\/10\/iterating-over-a-dictionary-in-python.webp","width":780,"height":400},{"@type":"BreadcrumbList","@id":"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.wscubetech.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Iterate Through a Dictionary in Python? (With Examples)"}]},{"@type":"WebSite","@id":"https:\/\/www.wscubetech.com\/blog\/#website","url":"https:\/\/www.wscubetech.com\/blog\/","name":"WsCube Tech Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wscubetech.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.wscubetech.com\/blog\/#\/schema\/person\/6995f82316ae760c1856b1bff807a793","name":"Ashima Jain","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wscubetech.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/7660a6dae5a26ff506f0be04c3c35807480f565ca201c63311fd4bfa47ff02a0?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/7660a6dae5a26ff506f0be04c3c35807480f565ca201c63311fd4bfa47ff02a0?s=96&d=mm&r=g","caption":"Ashima Jain"},"description":"Ashima Jain is a Content Editor and Strategist at WsCube Tech and has been in the content marketing industry for 6 years.","url":"https:\/\/www.wscubetech.com\/blog\/author\/ashima\/"},{"@type":"Question","@id":"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510879093","position":1,"url":"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510879093","name":"1. How to iterate through multiple dictionaries at one time?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"In Python, collections and itertools standard-library modules offer the ChainMap class and chain() function, respectively, that we can use to combine multiple dictionaries and iterate through them. However, these tools have a few basic differences. In the case of duplicate keys in input dictionaries, ChainMap provides only access to the first instance of a key, whereas chain() allows access to all the instances of repeated keys.\u00a0<br\/><br\/>We can also use the unpacking operator (**) to combine multiple dictionaries and iterate through the resulting dictionary. When the input dictionaries have duplicate keys, only the last instance of the repeated key will prevail.\u00a0","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510922557","position":2,"url":"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510922557","name":"2. How to iterate over key-value pairs in a dictionary?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"We can iterate over an item of a dictionary using a for loop. This will return key-value pairs.","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510941199","position":3,"url":"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510941199","name":"3. How to iterate through a dictionary in a specific order?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"We use the built-in sorted() function to iterate through a dictionary in a specific order. If fed with the result of .items(), the function will return a list of key-value tuples that we can traverse in a loop. We can also use the reversed() function to iterate through a dictionary in reverse order.\u00a0","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510949948","position":4,"url":"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510949948","name":"4. How to iterate over a dictionary while changing its content?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"To change or update the values of a dictionary, we can use a loop because dictionaries are mutable, so we can change their values easily. However, to remove key-value pairs from a dictionary while looping through it, use a copy for iteration and remove the values from the original dictionary. The copy() method allows you to create a shallow copy of a dictionary. The popitem() method is used with the while loop to remove consecutive items from a dictionary without making its copy.\u00a0","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510986416","position":5,"url":"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510986416","name":"5. How to get an iterable of dictionary values?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"We use the values() method in Python to get an iterable of values for a dictionary.","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510993556","position":6,"url":"https:\/\/www.wscubetech.com\/blog\/iterate-through-dictionary-python\/#faq-question-1729510993556","name":"6. How do we iterate over values in a dictionary?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"We use a for loop to iterate over the values of a dictionary in Python","inLanguage":"en-US"},"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.wscubetech.com\/blog\/wp-json\/wp\/v2\/posts\/11758","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wscubetech.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wscubetech.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wscubetech.com\/blog\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wscubetech.com\/blog\/wp-json\/wp\/v2\/comments?post=11758"}],"version-history":[{"count":21,"href":"https:\/\/www.wscubetech.com\/blog\/wp-json\/wp\/v2\/posts\/11758\/revisions"}],"predecessor-version":[{"id":17325,"href":"https:\/\/www.wscubetech.com\/blog\/wp-json\/wp\/v2\/posts\/11758\/revisions\/17325"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wscubetech.com\/blog\/wp-json\/wp\/v2\/media\/11851"}],"wp:attachment":[{"href":"https:\/\/www.wscubetech.com\/blog\/wp-json\/wp\/v2\/media?parent=11758"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wscubetech.com\/blog\/wp-json\/wp\/v2\/categories?post=11758"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wscubetech.com\/blog\/wp-json\/wp\/v2\/tags?post=11758"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}