I am new and I have a problem thats driving me nuts, i'm sure its very simple to an experienced CS but I'm attempting to execute a couple conditional statements.
basically, i am trying to write a program that determines the amount of shipping costs to inform the user of, in accordance to weight of an item. here is tha homework question followed by the code i have managed to mis-write.
tha company charges the following rates:
weight of package rate per pound
2 pounds or less $2.10
over 2 pounds but not more than 6pounds $3.20
over 6 pounds but not more than 10pounds $4.70
over 10pounds $4.80
write a prog that asks the user to enter tha weight of a package and then displays the shipping charges.
here is what i have whipped up so far....
#determine shipping charges according to weight print 'Welcome to Shipping Company Rate Calculator' shipweight=input ('Please Enter the Weight of the Item You Wish To Ship: ') def shipping_charges(): if shipweight>=2: print 'Your total shipping charges: $2.10' elif: if shipweight>2 or shipweight<6: print 'Your total shipping charges: $3.20' else: if shipweight>6 or shipweight<10: print 'Your total shipping charges: $4.70' else: if shipweight>10: print 'Your total shipping charges: $4.80' else: print 'Your total shipping charges: $4.80' shipping_charges()
I kinda butchered it while attempting to get it to run so there might by some random errors.
but it always tells me 'elif' or 'else' are invalid syntax..
haha maybe i should just re-read tha chapter.
as simple/dumb as this may seem im just looking for a little clarification on the if, elif and else structure. Any constructive input is greatly appreciated! Thanx in advance.