Jul-26-2020, 10:23 AM
(This post was last modified: Jul-26-2020, 10:24 AM by pyzyx3qwerty.)
I'm not sure if this is correct, but How about using a
break
?numItems = int(input("How many items are you buying?:")) #Initializes the amount of items and the price subPrice = 0 x = 0 #use conditional loop to loop until the price amount mathces with the number of items while x in range (0,numItems): price = int(input("Enter in a price: $")) #program asks for the price: numItems = numItems + 1 # Counts how many items entered subPrice = subPrice + price # Calculates the sum break #Calculates the tax and total price tax = subPrice * 0.13 tax2 = round (tax,2) Total = subPrice - tax total2 = round(Total,2) # prints out the Subtotal, tax and Total print ("Subtotal: $", subPrice) print ("Tax", tax2) print ("Total", total2)Note that on line 16, you have defined total with a capital T but in line 17, when you round Total, you don't use a capital T.
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs