Answers for "print keys in dictionary python using for loop"

16

python loop through dictionary

new_list = [something(key, value) for key, value in a_dict.items()]
Posted by: Guest on April-23-2020
6

for key value in dict python

a_dict = {"color": "blue", "fruit": "apple", "pet": "dog"}
for key in a_dict:
  print(key, '->', a_dict[key])

# Output:
# color -> blue
# fruit -> apple
# pet -> dog
Posted by: Guest on May-05-2020

Code answers related to "print keys in dictionary python using for loop"

Python Answers by Framework

Browse Popular Code Answers by Language