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
Post a Comment
Write something to CodeWithAbdur!