Defining A Function Inside A Function Python