dict = {"Pond":"A Lake", "Lake":"A Pond", "Book":"Bunch of Pages", "Chaddi":"The Undies" }
for key in dict: print(f"{Key}:{dict[key]}")
CodePudding user response:
You incorrectly capitalized the letter k. You wrote Key
. Use key
.
If d
is your dictionary (you should not use dict
as the name of your dictionary):
for key in d:
print(f"{key}:{d[key]}")
CodePudding user response:
The answer of @oda works perfect, and as they said that you Capitalized Key
. It should be key
.
You can also write like this:
for key in d:
print('{0}:{1}'.format(key,d[key]))