TypeError: must be str, not int

a=input('输入数:')
n=int(input('输入个数:'))
sum=0
b=0
for i in range(n):
    b=a*(10)**i+b
    print(b)
    sum=b+sum
print('和:%d'%sum)

The error is: b=a*(10)**i+b
TypeError: must be str, not int
Reason: a=input('input number:')##should be converted to an integer. Change
to:a=int(input('输入数:'))

Guess you like

Origin blog.csdn.net/jiahuiandxuehui/article/details/110677038