在Python中创建条件函数

2024-09-30 01:29:00 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图在python中基于一系列条件语句创建一个税收扣减计算函数。我的第一个条件“if”语句出现语法错误,不确定原因

1 = 'single'
2 = 'married filing jointly'
3 = 'head of household'

def deductions(income, filing_category): ## define function

    if ((filing_category = 1) and (income >= 12200)):
        return income - 12200
    elif((filing_category = 2) and (income >= 24400)):
        return income - 24400
    elif((filing_category = 3) and (income >= 18350)):
        return income - 18350
    else:
        return 'no taxes due'

q = deductions(10000, 1) ## call function
print(q) ## print result

如果有人能对我可能犯的语法错误提供一些见解,那就太好了。我是编程新手


Tags: and函数returniffunction语句条件税收

热门问题