Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In my dessertshop.py, in my Order class I have a __str__ method that prints to the terminal a table of all my dessert items in

In my dessertshop.py, in my Order class I have a __str__ method that prints to the terminal a "table" of all my dessert items in a nice formatted way. I have gotten rid of unnecessary commas in this __str__ method to make it look better. The output of this __str__ method is:

 

Name Quantity Unit Price Cost Tax
Gummy Bears  0.5lbs  $4/lb  $2.00  $0.14
Oatmeal Raisin Cookies  2 Cookies  $3.45/dozen  $0.57  $0.04
Pistachio Ice Cream  2 scoops  $0.79/scoop  $1.58  $0.11
Hot Fudge Vanilla Sundae  3 scoops  $0.69/scoop  $3.36  $0.24
Hot Fudge  1  $1.29

In my main function I am trying to feed to my data empty list every row in the output above as a list of lists (every row will be a list with those respective elements in each list) so that then I can import the list 'data' into receipt.py.

How can I iterate through this output, separate each element in each row as elements in a list, and created a list of lists in my data empty list?

dessertshop.py import dessert import receipt class Order(): definit_(self):  

 return order_str.replace( receipt.make_receipt (data) if __name____ ==  # Constructor with enough parameters to initialize all the # attributes of the object, including the def_str_(self): return f definit__(self, name= # creating the paragraph with # the heading text and passing the styles of it title = Paragraph  

dessertshop.py import dessert import receipt class Order(): definit_(self): """default constructor that takes no arguments and instantiates the order instance variable to a new list of DessertItem."** self.order = [] def add(self, dessert): """takes a single DessertItem and adds it to the empty list 'order'."** self.dessert = dessert self.order.append(dessert) deflen_(self): "*"magic method that returns the number of items in the list 'order'.*** return len(self.order) def order_cost (self, cost_list): """Calculates and returns the total cost for all items in the order."** return sum(cost_list) def order_tax(self, cost_list, tax_percent): """Calculates and returns the total tax for all items in the order.""" return cost_list * tax_percent def _str_(self): order_str "Name Quantity Unit Price Cost Tax " for dessert in self.order: order_strstr(dessert) + " "

Step by Step Solution

There are 3 Steps involved in it

Step: 1

To iterate through the output provided by the str method in the Order class of your dessertshoppy fi... 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

Taxation Of Individuals And Business Entities 2016

Authors: Brian Spilker, Benjamin Ayers, John Robinson, Edmund Outslay, Ronald Worsham, John Barrick, Connie Weaver

7th Edition

9781259425479, 125942121x, 1259334872, 1259425479, 9781259421211, 978-1259334870

More Books

Students also viewed these Programming questions