How to stop my reciept stop repeating itself

后端 未结 2 1729
轮回少年
轮回少年 2021-01-28 00:55

This is a program which asks a user to input a barcode , then my program finds the specified product , asks the user how many of a product they would like to purchase , if they

相关标签:
2条回答
  • 2021-01-28 01:42

    Well, it is not rounded as intended, because you store it as a String first and round it second.

    I would recommend to swap the lines values = [str(product), str(price), str(order*price)] and price = str(round(price,2))

    0 讨论(0)
  • 2021-01-28 01:48

    first try removing all the "global total_price" definitions in your functions.. (it would reset the variable each time) Secondly in your function search_user_input() i would change the line price = round(float(row[2]),2) into price = float(row[2]) (you can later use format to display the final float value in the desired format). Thirdly in your function quantity() you should change the line if continue_shopping !=0 and continue_shopping !=1: into if continue_shopping ==0 or continue_shopping ==1: , good luck

    0 讨论(0)
提交回复
热议问题