Ad
  • Default User Avatar

    a list is a structure that contains a series of values of any type.
    if we have a list like [10, 20, 30, 40] the first element (as in all computer science) is an elemet #0
    so we start counting from 0 not from 1 as in regular life.
    if we need to get the first element of the array (list) we use arr[0] (arr is a name of the array/list)
    when we iterate over the array using the for loop we get each consecutive element of that array with each loop.
    for i in data means "take each element of data one at a time".
    so at loop 0 we take the 0th element and write its value to the variable i
    here each element of the data list is a list itself, i.e. the 0th element is equal to [18, 20]
    so i[0] means 18 and i[1] means 20. if we try to get the 2nd element of the list i we would encounter an error because there is no 2nd element in this array/list.
    using words like 'key' and 'value' in this case is a bit wrong.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution