SyntaxError: “can't assign to function call”

后端 未结 4 1013
误落风尘
误落风尘 2020-11-30 11:33

This line in my program:

invest(initial_amount,top_company(5,year,year+1)) = subsequent_amount

causes me to get this error:



        
4条回答
  •  情话喂你
    2020-11-30 11:47

    You are assigning to a function call:

    invest(initial_amount,top_company(5,year,year+1)) = subsequent_amount
    

    which is illegal in Python. The question is, what do you want to do? What does invest() do? I suppose it returns a value, namely what you're trying to use as subsequent_amount, right?

    If so, then something like this should work:

    amount = invest(amount,top_company(5,year,year+1),year)
    

提交回复
热议问题