Adding Problem 27 in Python