Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Instructions Function Create a function format _ as _ price ( ) , with prices _ str as a parameter. The function returns a list

Instructions
Function
Create a function format_as_price(), with prices_str as a parameter. The function returns a list that stores each price formatted as a string with a dollar sign at the start and 2 decimal places.
Inside the function, turn the text stored in the prices_str 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 (i.e., with 2 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 format_as_price() 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts Of Database Management

Authors: Joy L. Starks, Philip J. Pratt, Mary Z. Last

9th Edition

1337093424, 978-1337093422

More Books

Students also viewed these Databases questions

Question

3. What are potential solutions?

Answered: 1 week ago