Discover the answers you need at Westonci.ca, a dynamic Q&A platform where knowledge is shared freely by a community of experts. Discover in-depth answers to your questions from a wide network of professionals on our user-friendly Q&A platform. Join our platform to connect with experts ready to provide precise answers to your questions in different areas.

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)
Thank you for trusting us with your questions. We're here to help you find accurate answers quickly and efficiently. Thanks for using our service. We're always here to provide accurate and up-to-date answers to all your queries. Westonci.ca is committed to providing accurate answers. Come back soon for more trustworthy information.