Question

Write a program that prompts the user to enter a list of names. Each persons 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 names first followed by the last names. A sample run of your program should look like Please enter your list of names: Epstein, Susan; St. John, Katherine; Vazquez-Abad, Felisa; Xu, Jia; Zamfirescu, christina You entered: Susan Epstein Katherine St. John Felisa Vazquez-Abad Jia Xu Christina Zamfirescu Thank you for using my name organizer! Hint: See Section 10.24 for a quick overview of split).Do this problem in parts: first, split the list by person (what should the delimiter be?). Then, split each of persons name into first and last name (what should the delimiter be here?).

0 0
Add a comment Improve this question Transcribed image text
Answer #1

string=raw_input("Please Enter Your list of names\n")
list1=list();
list1=string.split(";")    # splitting by semi colon
list2=list()
for i in range (0,(len(list1))):
    list2.append(list1[i].split(","))     .// splitiing by ","
for i in range (0,len(list2)):
    print list2[i][1],list2[i][0]+"\n"      // printing the values

print "Thank you for using my name organizer\n"

Code Screenshot :

string raw input (Please Enter Your list of names\n) listl-list) listi string.split(;) list2-list ( ) for i in range (, (len (listl))) list2. append (list! [1]·split ( , ) ) for i in range (o,len (list2)) print list2 [i] [1], list2[i] [0+n print Thank you for using my name organizern

OUTPUT :

if we have any queries please post a comment thank you .

Add a comment
Know the answer?
Add Answer to:
Write a program that prompts the user to enter a list of names. Each person's name...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program that reads a person's first and last names, separated by a space. Then...

    Write a program that reads a person's first and last names, separated by a space. Then the program outputs last name, comma, first name. End with newline. Example output if the input is: Maya Jones Jones, Maya import java.util.Scanner; public class SpaceReplace {    public static void main (String [] args) {       Scanner scnr = new Scanner(System.in);       String firstName;       String lastName; //answer goes here//    } }

  • Write a program that reads a person's first and last names, separated by a space. Then...

    Write a program that reads a person's first and last names, separated by a space. Then the program outputs last name, comma, first name. End with newline. Example output if the input is Maya Jones Tones, Maya import java . util·Scanner; public class SpaceReplace 4 public static void main (String [1 ares) f( Scanner scnr-new Scanner(System.in); String firstName; String lastName; Your solution goes here */ 10 12

  • Using C Programming, Write a program that prompts for the user's first and last names. Declare a third array that will hold the user's last name and first name, separated by a comma and space....

    Using C Programming, Write a program that prompts for the user's first and last names. Declare a third array that will hold the user's last name and first name, separated by a comma and space. Use loops to inter through the names one character at a time, storing them into the full name array. Don't forget about the terminating character. Sample run: Enter your first name: john Enter your last name: matthews First name: John Last name: Matthews Full name:...

  • 1. Write a program to input a list of names (strings) from the user and store...

    1. Write a program to input a list of names (strings) from the user and store them in an ArrayList. The input can be terminated by entering the empty string or by entering the string “quit”. 2. Add further functionality to your program so that it searches the ArrayList to find the first string and the last string according to dictionary ordering and then prints out these strings (names). Do this exercise without sorting the names in the ArrayList. For...

  • Write a Python program that keeps reading in names from the user, until the user enters...

    Write a Python program that keeps reading in names from the user, until the user enters 0. Once the user enters 0, you should print out all the information that was entered by the user. Use this case to test your program: Input: John Marcel Daisy Samantha Nelson Deborah 0 ================ Output: John Marcel Daisy 25 Samantha Nelson Deborah Hints: Create an array Names to hold the input names. Use the Names.append(x) function to add a new name to the...

  • JAVA Write a program that prompts the user to enter a file name, then opens the...

    JAVA Write a program that prompts the user to enter a file name, then opens the file in text mode and reads it. The input files are assumed to be in CSV format. The input files contain a list of integers on each line separated by commas. The program should read each line, sort the numbers and print the comma separated list of integers on the console. Each sorted list of integers from the same line should be printed together...

  • Write a program in C language that gets a list of names from user. The list...

    Write a program in C language that gets a list of names from user. The list ends when the user gives ‘quit’. The program should then print all the names provided by the user and the frequency of each name. Assume each name is at most of size 100 characters.

  • Python code. No use of def() or return. 7a)Create a program that asks the user for...

    Python code. No use of def() or return. 7a)Create a program that asks the user for their full name (first, middle, and last). You can assume that compound names, such as Jamie-Lynn are joined by a hyphen, that names are separated by a space and that the user enters their data in the correct format. The program should then separate the first name, middle name, and last name from the single string entered by the user and save each piece...

  • Write a python program that prompts the user for the names of two text files and...

    Write a python program that prompts the user for the names of two text files and compare the contents of the two files to see if they are the same. If they are, the scripts should simply output “Yes”. If they are not, the program should output “No”, followed by the first lines of each file that differ from each other. The input loop should read and compare lines from each file. The loop should break as soon as a...

  • Task 1: Write a Python program that takes as input from the user the name of a file containing po...

    python code: Task 1: Write a Python program that takes as input from the user the name of a file containing postcode/location information. Each line in the file consists of the postcode followed by a tab followed by a comma-separated list of locations that have that postcode. For example, the file Small.txt contains: 3015 Newport,South Kingsville,Spotswood 3016 Williamstown 3018 Altona,Seaholme 3019 3021 Albanvale,Kealba,Kings Park,St Albans Braybrook, Robinson Your program should create a list of postcode/location pairs with each pair stored...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT