Discover the answers you need at Westonci.ca, where experts provide clear and concise information on various topics. Join our Q&A platform to get precise answers from experts in diverse fields and enhance your understanding. Our platform offers a seamless experience for finding reliable answers from a network of knowledgeable professionals.

Complete the code to finish this program to analyze the inventory for a store that sells purses and backpacks. Each record is composed of the catalog number, the type of item, its color, the length, width, height, and the quantity in stock. Sample rows of the file are below. 234,purse,blue,12,4,14,10 138,purse,red,12,4,14,4 934,backpack,purple,25,10,15,3 925,backpack,green,25,10,15,7 import csv fileIn = open("data/bags.txt","r") countPurse = 0 textFile= csv.(fileIn) for bag in textFile: if bag[1] == 'purse': countPurse = countPurse + int(bag[6]) fileIn.close() print("Number of purses:",countPurse)

Sagot :

import csv
fileIn = open("data/bags.txt","r")
countPurse = 0
textFile= csv.reader(fileIn)
for bag in textFile:
if bag[ 1 ] == 'purse':
countPurse = countPurse + int(bag[6])
fileIn.close()
print("Number of purses:",countPurse)
We appreciate your time. Please come back anytime for the latest information and answers to your questions. Thank you for your visit. We're committed to providing you with the best information available. Return anytime for more. Thank you for visiting Westonci.ca, your go-to source for reliable answers. Come back soon for more expert insights.