小编aka*_*kaa的帖子

isdigit不适合我

def listMaker(a, b):
    if b.isdigit() == False:
         print("Sorry is not a valid input")
    else:
         newList = [a] * b
         return newList
Run Code Online (Sandbox Code Playgroud)

我收到错误:

AttributeError: 'int' object has no attribute 'isdigit'
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?

python python-2.7

5
推荐指数
1
解决办法
6421
查看次数

标签 统计

python ×1

python-2.7 ×1