Could this be solve with list comprehension?