Question: Instructions Function Create a function format _ as _ price ( ) , with prices _ str as a parameter. The function returns a list
Instructions
Function
Create a function formatasprice with pricesstr as a parameter. The function returns a list that stores each price formatted as a string with a dollar sign at the start and decimal places.
Inside the function, turn the text stored in the pricesstr into a list.
Loop over the elements in the list and convert each string into a float. Assume that each item in the string is a valid float.
Finally, turn each float into a string, formatted as a price ie with decimal places that also has a $ at the start.
Add each formatted string to the list that's returned at the end of the function.
Main program
In your main program:
Take a string as input: this is the text that is input into the function.
Call the function formatasprice to get the formatted list into your main program.
Output each item on the list
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
