TypeError: unsupported operand type(s) for -: 'str' and 'int'

前端 未结 2 1088
死守一世寂寞
死守一世寂寞 2020-11-22 13:30

New to python and programing how come I\'m getting this error?

def cat_n_times(s, n):
    while s != 0:
        print(n)
        s = s - 1

text = input(\"Wh         


        
2条回答
  •  花落未央
    2020-11-22 14:09

    For future reference Python is strongly typed. Unlike other dynamic languages, it will not automagically cast objects from one type or the other (say from str to int) so you must do this yourself. You'll like that in the long-run, trust me!

提交回复
热议问题