Can I have some help making a program that has the user append 5 names into a list using a loop? The names need to be in the format LastName-FirstName, with the – separating first/last. Then, using a second loop, split each name based on -.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Can I have some help making a program that has the user append 5 names into a list using a loop? The names need to be in the format LastName-FirstName, with the – separating first/last. Then, using a second loop, split each name based on -. 

Expert Solution
Step 1: Algorithm :

1. Create an empty list called names_list.
2. Create an empty list called split_names_list.
3. Use a loop to repeat the following steps 5 times:
   a. Prompt the user to enter a name in the format "LastName-FirstName" and store it in a variable called name.
   b. Append the name to the names_list.
4. Use a loop to iterate over each name in names_list:
   a. Split each name based on the '-' character and store the resulting last name and first name in variables.
   b. Create a tuple containing the last name and first name.
   c. Append the tuple to the split_names_list.
5. Print "Split Names:" to the console.
6. Use a loop to iterate over each tuple in split_names_list:
   a. Print the last name and first name in the format "Last Name: [last_name], First Name: [first_name]" to the console.
7. End the program.

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Mergesort
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education