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

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

    Python allows for you to multiply sequences to repeat their values. Here is a visual example:

    >>> [1] * 5
    [1, 1, 1, 1, 1]
    

    But it does not allow you to do it with floating point numbers:

    >>> [1] * 5.1
    Traceback (most recent call last):
      File "", line 1, in 
    TypeError: can't multiply sequence by non-int of type 'float'
    

提交回复
热议问题