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 -.
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 -.
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.
Step by step
Solved in 3 steps with 1 images