Advance Code Of Python Function