Ask Question
25 January, 14:55

write a program that prompts the user to enter a list of names. each person's name is separated from the next by a semi-colon and a space ('; ') and the names are entered lastname, firstname (i. e. separated by ', '). your program should then print out the names, one per line, with the first initial of the first name, followed by ".", and followed by the last name.

+1
Answers (1)
  1. 25 January, 15:21
    0
    names = input ()

    names = names. split ('; ')

    for name in names:

    splited_name = name. split (',')

    print (splited_name[1][0], '.', splited_name[0])

    Explanation:

    I'm gonna give you a answer in python, and explane each line next

    Step 1: Read the string of names

    names = input ()

    Step 2: Get splited each name by semicolon '; '

    names = names. split ('; ')

    Step 3: Loop in all names

    for name in names:

    Step 4: Get a name and last name splited:

    splited_name = name. split (',')

    Step 5: Print the first character of the name with '.' and the last name

    print (splited_name[1][0], '.', splited_name[0])
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “write a program that prompts the user to enter a list of names. each person's name is separated from the next by a semi-colon and a space ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers