May-29-2018, 01:55 PM
This is another question I got.
It given a lists of items and price tags of them.
It wanted to print out a receipt.
However, I couldn't one shot print all at once...
Is there any code possible to store the Inputs then print ALL at once in a proper table (Or receipt)?
This is so far I managed to do:
This is the output I was hoping for:
It given a lists of items and price tags of them.
It wanted to print out a receipt.
However, I couldn't one shot print all at once...
Is there any code possible to store the Inputs then print ALL at once in a proper table (Or receipt)?
This is so far I managed to do:
prodcodes = ['AAA', 'BBB', 'CCC', 'DDD', 'EEE', 'FFF'] price = [5.00, 7.00, 2.30, 1.70, 9.00, 10.50] n = len(prodcodes) print("\n\t\t\t\t\t\t\t\tMyShop\n\n\t\t\t\tProdcode\tQuantity\tPrice\tAmount(RM)") sum = 0 for i in range(n): line = str(input("Enter ProdCode (x to exit): ")) line = line.upper() if line == 'X': break eqty = int(input("Enter Quantity: ")) for i in range(n): if line == prodcodes[i]: amount = eqty * price[i] print("\n\t\t\t\t\t{0}\t\t{1}\t{2:.2f}\t{3:.2f}".format(prodcodes[i],eqty,price[i],amount)) sum = sum + amount print("\n\t\t\t\t\tTotal amount: {:.2f}".format(sum))Much thanks!

This is the output I was hoping for:
Output: MyShop
Prodcode Quantity Price Amount(RM)
AAA 2 5.00 10.00
DDD 4 1.70 6.80
EEE 1 9.00 9.00
Total amount: 25.80