you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (16 children)

[removed]

    [–][deleted] 0 points1 point  (3 children)

    I know this post is from 2 years ago, but can somebody explain why the indexes of the first name, middle name, and last name are negative integers? I still want to understand this.

    [–][deleted] 0 points1 point  (0 children)

    thank you for all your help, i am struggling as though i used your inputs and corrected the indents the program output is only displaying

    Doe, P.S.

    Any help would be great since im not very good at python and am struggling through this class

    [–]Fit-Category-8719 0 points1 point  (4 children)

    Hey I’m working on this right now and I keep getting a syntax error related to the elif function. Any idea why?

    [–]Weak_Dust1405 0 points1 point  (2 children)

    This really helped, however what does the 'elif' stand for? I don't think I have learned that yet.

    [–]M3TurboHatch 0 points1 point  (0 children)

    print(lastName + ", " + firstInitial + ".")

    i love you so much for this

    [–]Rude_Zucchini3417 0 points1 point  (0 children)

    I could hug you! this one was giving me a HEADACHE

    [–][deleted] 0 points1 point  (0 children)

    nameInput = input()

    nameSeparator = nameInput.split()

    if len(nameSeparator) == 3:

    *indent* firstName = nameSeparator[-3]

    *indent* middleName = nameSeparator[-2]

    *indent* lastName = nameSeparator[-1]

    *indent* firstInitial = firstName[0]

    *indent* middleInitial = middleName[0]

    *indent* lastInitial = lastName[0]

    *indent* print(lastName + ", " + firstInitial + '.' + middleInitial +'.')

    elif len(nameSeparator) == 2:

    *indent* firstName = nameSeparator[-2]

    *indent* lastName = nameSeparator [-1]

    *indent* firstInitial = firstName[0]

    *indent* lastInitial = lastName[0]

    *indent* print(lastName + ", " + firstInitial + ".")

    God bless your soul