Access a Dictionary Key Value Present Inside a List Last Updated : 12 Feb, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report The dictionary is a data structure in Python. A Dictionary in Python holds a key-value pair in it. Every key in the dictionary is unique. A value present in Dictionary can be accessed in Python in two different ways. A list can hold any data structure to it. A list can also contain a dictionary in it. In this article, we will see how to access a dictionary key value present inside a list in Python. Access A Dictionary Key Value Present Inside a ListBelow are some of the ways by which we can access a dictionary key value present inside a list in Python: Using square bracketsUsing get() methodUsing for loopAccess A Dictionary Key Using square bracketsIn this example, a dictionary "companies" associates tech company names with their founders. The code then retrieves the founder of "Meta" from the list "myList" and prints the result, yielding "Mark Zuckerberg." Python3 companies = {"Microsoft": "Bill Gates", "Meta": "Mark Zuckerberg", "Tesla": "Elon Musk", "Google": "Sundar Pichai", "iPhone": "Tim Cook"} myList = ["Hello", companies, "12345", 100] answer = myList[1]["Meta"] print(answer) OutputMark Zuckerberg Access A Dictionary Key Using get() methodIn this example, a dictionary "companies" associates tech company names with their founders. The code retrieves the founder of "Google" from the list "myList" using the `get` method and prints the result, yielding "Sundar Pichai" or `None` if the key is not found. Python3 companies = {"Microsoft": "Bill Gates", "Meta": "Mark Zuckerberg", "Tesla": "Elon Musk", "Google": "Sundar Pichai", "iPhone": "Tim Cook"} myList = ["Hello", companies, "12345", 100] answer = myList[1].get("Google") print(answer) OutputSundar Pichai Access A Dictionary Key Using for loopIn this example, there's a dictionary "student" with keys "name," "age," and "lastName." The dictionary is then placed in a list called "sampleList." The code iterates through the list, and for each dictionary in the list, it iterates through key-value pairs using the items() method. Python3 student = {"name": "Alice", "age": 10, "lastName": "John"} sampleList = [student] for element in sampleList: for studentKey, studentValue in element.items(): print(studentKey, "=", studentValue) Outputname = Alice age = 10 lastName = John Comment More infoAdvertise with us Next Article How to Access Dictionary Value by Key in TypeScript ? R reshmah Follow Improve Article Tags : Python Practice Tags : python Similar Reads How to Access Dictionary Value by Key in TypeScript ? Dictionaries are often represented as the objects where keys are associated with the specific values. These TypeScript dictionaries are very similar to JavaScript objects and are used wherever data needs to be stored in key and value form. You can use the below method to access the dictionary values 2 min read How to use a List as a key of a Dictionary in Python 3? In Python, we use dictionaries to check if an item is present or not . Dictionaries use key:value pair to search if a key is present or not and if the key is present what is its value . We can use integer, string, tuples as dictionary keys but cannot use list as a key of it . The reason is explained 3 min read How to use a List as a key of a Dictionary in Python 3? In Python, we use dictionaries to check if an item is present or not . Dictionaries use key:value pair to search if a key is present or not and if the key is present what is its value . We can use integer, string, tuples as dictionary keys but cannot use list as a key of it . The reason is explained 3 min read Python - Keys associated with value list in dictionary Sometimes, while working with Python dictionaries, we can have a problem finding the key of a particular value in the value list. This problem is quite common and can have applications in many domains. Let us discuss certain ways in which we can Get Keys associated with Values in the Dictionary in P 4 min read Python - Keys associated with value list in dictionary Sometimes, while working with Python dictionaries, we can have a problem finding the key of a particular value in the value list. This problem is quite common and can have applications in many domains. Let us discuss certain ways in which we can Get Keys associated with Values in the Dictionary in P 4 min read Python - Access Dictionary items A dictionary in Python is a useful way to store data in pairs, where each key is connected to a value. To access an item in the dictionary, refer to its key name inside square brackets.Example:Pythona = {"Geeks": 3, "for": 2, "geeks": 1} #Access the value assosiated with "geeks" x = a["geeks"] print 3 min read Like