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

后端 未结 6 1194
傲寒
傲寒 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:59

    In this line:

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

    growthRates is a sequence ([3,4,5,0,3]). You can't multiply that sequence by a float (0.1). It looks like what you wanted to put there was i.

    Incidentally, i is not a great name for that variable. Consider something more descriptive, like growthRate or rate.

提交回复
热议问题