python homework using recursive functions