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

How come I’m getting this error?

My code:

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

text = input("What would you like the computer to repeat back to you: ")
num = input("How many times: ")

cat_n_times(num, text)

Error:

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

Leave a Comment