name = re.search(r"^([\w \.-]), ([\w \.-])$", list_name)
Explanation:
Regular expression is used to simplify the mode in which items in a data structure are for. It uses wildcards as shortcuts.
The python module for regular expression is 're'. The import statement is used to get the module and the search() method of the module is used to get the one matching item while the findall() method is used to get a list of all the matching items in a data structure.