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:
handling cases where the element is an
int
orfloat
and printNone
for length.recursively printing out the length of all elements which are nested sequences.
['spam!', 1, ['Brie', 'Roquefort', 'Pol le Veq'], [1, 2, 3]]