Ask 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 ('; ') 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.

+4
Answers (1)
  1. 14 March, 11:37
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers