Python Function Not Updating Variable