Question
product=0 number=0 total_price=0 total_amount=0 while(number!=4): number=int(input( Watchmen Security Supply 1. Add to Inventory 2. View Inventory 3. Product Report 4. Exit )) if(number==1): product=int(input( Enter
product=0 number=0 total_price=0 total_amount=0
while(number!=4): number=int(input(" Watchmen Security Supply 1. Add to Inventory 2. View Inventory 3. Product Report 4. Exit ")) if(number==1): product=int(input(" Enter number of product to add:")) for i in range(0,product): name=input(" Enter name:") price=int(input("Enter price:")) amount=int(input("Enter amount:")) item.append([name,price,amount]) if(number==2): print("Name\tPrice\tAmount ") for i in range(0,product): print(item[i][0],"\t",item[i][1],"\t",item[i][2]," ") if(number==3): for i in range(product): total_price += item[i][1]*item[i][2] total_amount += item[i][2] print(" Total price = ",total_price," Total Amount = ", total_amount)
output:
Watchmen Security Supply 1. Add to Inventory 2. View Inventory 3. Product Report 4. Exit 1 Enter number of product to add: 4 Enter name: q Enter price: 2 Enter amount: 3 Enter name: e Enter price: 4 Enter amount: 32 Enter name: q Enter price: 2 Enter amount: 3 Enter name: r Enter price: 1 Enter amount: 2 Watchmen Security Supply 1. Add to Inventory 2. View Inventory 3. Product Report 4. Exit 3 Total price = 6 Total Amount = 3 Total price = 134 Total Amount = 35 Total price = 140 Total Amount = 38 Total price = 142 Total Amount = 40
//can't figure out why I am getting total of every price and amount entered. I want it to only print the total price and total amount of all item entered.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started