Chapter 5 Exercise Set 4: Recursion Exercise

Counting the length of sequences by traversal revisited

In Counting the length of sequences by traversal you were asked to traverse a sequence and print out the length of each element. In this exercise you will improve on that solution by:

  1. handling cases where the element is an int or float and print None for length.

  2. recursively printing out the length of all elements which are nested sequences.

['spam!', 1, ['Brie', 'Roquefort', 'Pol le Veq'], [1, 2, 3]]