# Iterate over a dictionnary - Python
Data Science for Political and Social Phenomena
Author: Guillaume Redoulès

# Iterate over a dictionnary

To iterate over a dictionnary in a for loop, you have to use the following syntaxe

    for key, value in d.items():

Here is a examples printing the keys and values of a dictionnary

    d = {"key1":"value 1", "key2": "value 2", "key3" :"value 3"}

    for key, value in d.items():
        print(f'{key} : {value}')

    key1 : value 1
    key2 : value 2
    key3 : value 3

### Find an error or bug? Have a suggestion?

Everything on this site is avaliable on GitHub. Head on over and submit an issue. You can also message me directly by email.