mercredi 7 décembre 2016

Python nested if-else only executed else

I have this exercise , calculates the cost of sending a small parcel. Te post office charges R5 for the first 300g, and R2 for every 100g thereafter (rounded up), up to a maximum weight of 1000g .

weight = raw_input("What are the weight of you parcel: ")    

if weight <= 1000:
   if weight <= 300:
      cost = 5
     print("You parcel cost: " + cost)
   else:
      cost = 5 + 2 * round((weight - 300)/ 100)
      print("You parcel cost: " + cost)
else:
    print("Maximum weight for amall parcel exceeded.")
    print("Use large parcel service instead.")

When i execute the IDLE console , I come only the last else statements.

Aucun commentaire:

Enregistrer un commentaire