Did #45 in python