Defining Functions Inside Functions Python Code For Leap