2017-10-05 223 views
0

我正在试图制作一个程序,要求客户输入他们想要购买的物品的数量。然后程序会找到小计和总税金。我对如何添加一个while循环感到困惑,以至于它会一直询问项目的价格,具体取决于用户放置了多少项目,然后将所有项目一起添加。Python - While循环

回答

0

您必须添加您尝试过的以及您卡住的位置。这是一个开始的伪代码。

read the number of items as num 
initialise total to zero 
while num > 0: 
    read the price of the each item as price 
    calculate the tax and add it to price 
    add the taxed price of each item to total 
    decrement num 
print sum