Skip to content

Instantly share code, notes, and snippets.

@AnisahTiaraPratiwi
Created March 23, 2021 07:42
Show Gist options
  • Save AnisahTiaraPratiwi/f63ef7a219cb46894add7f2d9af93d9f to your computer and use it in GitHub Desktop.
Save AnisahTiaraPratiwi/f63ef7a219cb46894add7f2d9af93d9f to your computer and use it in GitHub Desktop.
Now, it's your turn! Have a go at iterating over a dictionary! Complete the code to iterate through the keys and values of the cool_beasts dictionary. Remember that the items method returns a tuple of key, value for each element in the dictionary.
cool_beasts = {"octopuses":"tentacles", "dolphins":"fins", "rhinos":"horns"}
for animal, thing in cool_beasts.items():
print("{} have {}".format(animal, thing))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment