Defining Functions Inside Functions Python Code