Looping

Dictionary items may be accessed with a for loop.

dictionary = {
    'cat': 'Frisky',
    'dog': 'Spot',
    'fish': 'Bubbles',
}

for key in dictionary:
    print("dictionary[%s]: %s" % (key, dictionary[key]))



Output:

dictionary[dog]: Spot
dictionary[fish]: Bubbles
dictionary[cat]: Frisky

results matching ""

    No results matching ""