Question: I have been laboring on this problem and I keep getting this darn error every time I run the code. I sure hope you can

I have been laboring on this problem and I keep getting this darn error every time I run the code. I sure hope you can help me with this problem. Thanks for all your help.

name = input()

split_name - name.split()

firstName - split_name[0]

middleName = spli_name[1]

if len(split_name) --2:

print(middleName + ',', firstName[0:1] + '.')

if len(split_name) --3:

lastName = split_name[2]

print(lastName + ',', firstName[0:1] + '.' + middleName[0:1] + '.')

Traceback (most recent call last):

File "main.py", line 3, in

split_name - name.split()

NameError: name 'split_name' is not defined

Ex: If the input is:

Pat Silly Doe 

the output is:

Doe, P.S. 

If the input has the form:

firstName lastName

the output is:

lastName, firstInitial.

Ex: If the input is:

Julia Clark 

the output is:

Clark, J. 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!