elif声明不起作用

时间:2014-11-04 20:49:24

标签: python indentation

我为此感到抱歉,但我是一个完全的初学者,无论我尝试什么,它都会出错。任何人都可以给我一个小小的想法,我的elif声明出了什么问题,所以我可以坚持下去吗? (我也知道目前0%的错误为1%,只是测试理论)

one = (1)
three = (2)
four = (4)
five = (5)
seven = (7)

stampduty = int(input("Enter amount of residential property"))

if stampduty >= 1 and stampduty<=125000:
    add = (stampduty*one/100.0)
    addamount = stampduty + add
    print("Stamp Duty percent 0% \nyour stamp duty amount is", addamount)
elif:
    add =  add = (stampduty*one/100.0)
    addamount = stampduty + add
    print("Stamp Duty percent 0% \nyour stamp duty amount is", addamount)

2 个答案:

答案 0 :(得分:7)

elif需要一个条件,就像if语句一样。如果您想要无条件阻止,请使用else

if stampduty >= 1 and stampduty<=125000:
    add = (stampduty*one/100.0)
    addamount = stampduty + add
    print("Stamp Duty percent 0% \nyour stamp duty amount is", addamount)
else:
    add =  add = (stampduty*one/100.0)
    addamount = stampduty + add
    print("Stamp Duty percent 0% \nyour stamp duty amount is", addamount)

答案 1 :(得分:0)

也许您应该使用else代替elif。 在elif中,与if中一样,您需要传递条件。