Below is the code I use.
# display a welcome message
print("===============================================================")
print("Shipping Calculator")
print("===============================================================")
while True:
# get input from the user
cost_of_items = float(input("Cost of items ordered: "))
# make sure input is a positive number
if cost_of_items < 0:
print("You must enter a positive number. Please try again.")
continue
# to do: get shipping cost(one given for example)
if cost_of_items < 30:
shipping_cost = 5.95
if 30.00 < cost_of_items < 49.99:
shipping_cost = 7.95
if 50.00 < cost_of_items < 74.99:
shipping_cost = 9.95
if cost_of_items > 75:
shipping_cost = 0
# To do: calculate total cost: total_cost
total_cost = cost_of_items + shipping_cost
# to do: display in output, print shipping cost, print total cost
print(shipping_cost,total_cost)
# to do: make your program more interesting, ask user how many item like to ship,
num_of_items = float(input("Number of items to ship: "))
# and caclutate the cost of shipping based on total cost
total_shipping_cost = shipping_cost*num_of_items
final_total_cost = cost_of_items + total_shipping_cost
print(total_shipping_cost, final_total_cost)
# see if the user wants to continue
choice = input("Continue? (y/n): ")
print("===============================================================")
if choice.lower() != "y":
break
print("Bye!")
Here is the output I get: enter image description here
but I want the output to display like:
How can I do that? to put some description before the output? like Number of items to ship: X, Total Shipping cost: XX