Iterating over Python Dictionaries

Python dictionaries are iterables.

mydict = {
    "table" : "wood",
    "bangle" : "gold",
    "window" : "glass",
    "body" : "mud",
    "shopper" : "plastic",
    "protein" : "amino acids"
}
for item, material in mydict.items():
    print(f"The {item} is made out of {material}.")

Result:
The table is made out of wood. The bangle is made out of gold. The window is made out of glass. The body is made out of mud. The shopper is made out of plastic. The protein is made out of amino acids.


 

Comments

Popular posts from this blog

Quotation marks to wrap an element in HTML

The Basic Structure of a Full-Stack Web App

Unlocking Web Design: A Guide to Mastering CSS Layout Modes