can't multiply sequence by non-int of type 'float'

后端 未结 6 1209
傲寒
傲寒 2020-12-15 03:22

level: beginner

why do i get error \"can\'t multiply sequence by non-int of type \'float\'\"?

def nestEgVariable(salary, save, growthRates):
    Sav         


        
6条回答
  •  天命终不由人
    2020-12-15 03:43

    In this line:

    fund = fund * (1 + 0.01 * growthRates) + depositPerYear
    

    I think you mean this:

    fund = fund * (1 + 0.01 * i) + depositPerYear
    

    When you try to multiply a float by growthRates (which is a list), you get that error.

提交回复
热议问题