PY3.C0206
Use dict items
Emitted when iterating over the keys of a dictionary and accessing the valueby index lookup. Both the key and value can be accessed by iterating using the .items() method of the dictionary instead.
Noncompliant Code:
Copy
                                                    
                                                
                                                ORCHESTRA = {
    "violin": "strings",
    "oboe": "woodwind",
    "tuba": "brass",
    "gong": "percussion",
}
for instrument in ORCHESTRA:
    print(f"{instrument}: {ORCHESTRA[instrument]}")
Compliant Code:
Copy
                                                    
                                                
                                            ORCHESTRA = {
    "violin": "strings",
    "oboe": "woodwind",
    "tuba": "brass",
    "gong": "percussion",
}
for instrument, section in ORCHESTRA.items():
    print(f"{instrument}: {section}")