Solved problem10 in python3