python 中变量的语法无效

Invalid Syntax on variables in python

我可以知道为什么在第一个 elif 循环中我的 f 变量语法无效吗?

def bsd():
if price_of_properties <= 180000:
    price = 180000*0.1
    f = '{0:.2f}'.format(price)
    print("BSD is $" + str(f))
elif price_of_properties > 180000 <= 360000:
    price = (((180000*0.1) + (price_of_properties - 180000 + (180000* 0.2)))
    f = '{0:.2f}'.format(price)
    print("BSD is $" + str(f))
elif price_of_properties > 360000 <= 100000:
    price = (((180000*0.1) + (180000*0.2) +(price_of_properties - 180000 + (640000* 0.3)))
    f = '{0:.2f}'.format(price)
    print("BSD is $" + str(f))

你对价格变量的第二次和第三次赋值有不平衡的括号((打开多于关闭)。

虽然我 认为 Python 3.11 可能会修复此问题,但它会导致以下几行出现错误,从而更准确地报告错误。您可以通过在这两行中的每一行上添加右括号来解决此问题。或删除第一个。但是在你这样做之后检查公式,以防你做出错误的选择。

而且,是的,第一段中的额外左括号是有意的:-)