Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

for loop items dictionary in python

jjj = {'chuck': 1, 'fred': 42, 'jan': 100}
# If you want only the keys
for key in jjj:
    print(key)
# if you want only the values
for key in jjj:
    print(jjj[key])
# if you want both keys and values with items
# Using the above you can get either key or value separately if you want
for key, value in jjj.items():
    print(key, value)
Source by www.py4e.com #
 
PREVIOUS NEXT
Tagged: #loop #items #dictionary #python
ADD COMMENT
Topic
Name
9+1 =