Respuesta :

The regular expression used in the rearrange_name function is

import re

def rearrange_name(name):

result = re.search(r"^([\w \.-]), ([\w \.-])$", name)

if result == None:

return name

return "{} {}".format(result[2], result[1])

name=rearrange_name("Kennedy, John F.")

print(name)

What is programming?

Programming is the process of computing or designing a computer program. It is a set of instructions which performs specific function. It is also the writing of codes to facilitate software programs.

There are different types of programming language which includes:

  • Java
  • Python
  • SQL
  • Java script
  • PHP etc

Learn more about programming:

https://brainly.com/question/20970461

The fix to the regular expression in the rearrange_name function is:

result = re.search(r"^([\w \.-]), ([\w \.-])$", name)

In programming, regular expressions are defined patterns used in string variables and values to match the required output.

From the complete program, the first line imports the regular expression module as re.

So, we make use of the module name "re" to control the regular expression.

The regular expression that gives the required string format is:

result = re.search(r"^([\w \.-]), ([\w \.-])$", name)

Where:

  • [\w \.-] is used to match the names
  • re is the variable name used for the regular expression

Read more about python programs at:

https://brainly.com/question/14284563

ACCESS MORE
EDU ACCESS