Question: Create a python code for the given problem. Please include an interface for the user to type the input value. Problem B: Formatting a List
Create a python code for the given problem. Please include an interface for the user to type the input value.
Problem B: Formatting a List
FOR LOOP PROBLEMS
When writing out a list in English, one normally separates the contents with commas. In
addition, the word "plus" is normally included before the last item, unless the list only
contains one item, or two itemsno oxford comma Consider the following:
"Sora"; "Kairi plus Rikku"; "keyblades, heartless, plus nobodies"; "dreams, memories, fates, plus worlds"
Write a function called formatList that takes a list of strings as its only parameter. Your
function should return a string that contains all of the items in the list formatted in the
manner described previously as its only result. While the examples shown previously only
include lists containing four elements or less, your function should behave correctly for lists
of any length.
End your code with a call to the print function containing formatList as its only parameter.
formatList should have the input function as a parameter as well. Finally, use split on the input
function, with a single comma as a parameter inside split.
Sample Run #
Sora
Sora
Sample Run #
Kairi,Rikku
Kairi plus Rikku
Sample Run #
keyblades, heartless, nobodies
kevblades, heartless, plus nobodies
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
