Question: Hello. Please check my code. Im getting an error message line 23 I inventoryValue . append(lineItems... TypeError::cant multiply sequence by non-int of type float. .
File Edit Format Run Options Window Help # Instructors folder CSV file called Inventory, tt # Read contents of file and out put a file called InventoryByxxx.txt. # File will contain lines displaying the following: # COUNT of items, ITEM CODE, GENERAL name, SPECIFIC name, SIZE, TYPE, PRICE per. # Example of line: 228, SEA-13189, Pepper, Florida, 8 oz., Seasoning, 8.75 Display as Florida Pepper space> value of inventory. # where the name will be dLSplayed with the SPECIFIC portion followed by the # GENERAL portion of name seperated by one space and amount will appear with t two decimal digits with commas in neatly arranged (decimals alligned, columnar # display output file. Add write one additional line to the file which will be TOTAL INVENTORY which is total of the value of all items. Allign all in columns, commas as necessary, decimal places aligned. specificName- [] #Lists that hold data generalName inventoryValue- readFile -open(Inventory.txt,open file tor processing for line in readFile.readlines(): #iterating over each line lneltens-line.split(',') #splitting on comma and space specificName.append(line 1 tens [3]) #addinf respective parall lists generalName.append (1ineItems (2]) inventoryValue.append (inelcems to1loat (ineItems (6])) #writing results t output file InventoryByxxx open('Inventory.txt',w for i n range (0,len (specficName)) : #iterating over list nventoryByxxx.write (specifickame[1]+..+generalsamei))twriting InventoryByxxx.write( total!nvvalue +-invvalue [1] #accumulator resulta yByxxx.write("Total Inventory\t') #writing total to inventory value Inventor InventoryByxxx.write:6n.format (totalInvWalue), InventoryByxxx.close) Ln: 2 Col: 0 DOLL
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
