Session Ready
Exercise

Dataset dimensions

The output from the previous exercise was a nested list, or more specifically a list of lists of strings.

Next, we will define a function called flatten() to flatten this list of lists into a simple list.

In this exercise, we will use generator expressions instead of list comprehensions.

Generators remember which values they have already generated.

This allows us to use the zip() function to elegantly pair the numbers we will extract from the matches variable.

As zip() pairs numbers, the number generator will keep track of which numbers come next until it runs out of values.

After we use zip() to pair up the number of rows and columns from each dataset description, we will use zip() again to match dataset names and dimensions.

Instructions
100 XP
  • First, use flatten() to obtain each list from the list of lists.
  • Then, extract each element from every list so that the strings can be combined into one final list.