bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths

Loading lesson path

Learn/Python/Foundations
Python•Foundations

Python - Loop Dictionaries

Loop Through a Dictionary

You can loop through a dictionary by using a for loop.

When looping through a dictionary, the return value are the keys of the dictionary, but there are methods to return the values as well.

Example

for x in thisdict:
  print(x)

Example

for x in thisdict:
  print(thisdict[x])
values()
keys()
items()

Previous

Python - Remove Dictionary Items

Next

Python - Copy Dictionaries