I'd do both of these with list comprehensions.