Solved problem28 in python3