Looping through Dictionaries



Looping Through Lists containing Dictionaries

This is perhaps the most common process that you will carry out in your programming.

There are two ways to loop through the List of Dictionaries:

Method 1: Using the Index value

This method relies on the facts that:

  1. a list has numbered elements starting with an ordinal value of 0
  2. a list has a length
  3. a for loop can be made to step through a range of values



image of loop by index


Method 2: Using an Object

This method relies on the facts that:

  1. a dictionary is an object – JSON
  2. each object can be dealt with in turn
  3. each object has properties that are accessed using the keys



image of loop by object