Python Function Modify Input And Output