Python 3错误:ValueError:基数为10的int()的无效文字:''

Abh*_*hek 1 python python-3.x

我已经编写了代码来解决问题.

这是我的代码:

t=int(input())
print("")
while(t):
    s=0
    n=int(input())
    for i in range(n):
        no=int(input())
        s=s+no
    if s%n==0:
        print("YES")
    else:
        print("NO")
    print("")
    t-=1
Run Code Online (Sandbox Code Playgroud)

当我在OS X终端上运行它时,它工作正常.但是当我运行它IDEone或将其作为解决方案提交时,它会给出错误line 5:

ValueError:基数为10的int()的无效文字:''

我不确定问题是什么.

Cor*_*mer 5

如果用户没有输入任何内容,换句话说就是空字符串,则不进行处理

>>> int('')
Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    int('')
ValueError: invalid literal for int() with base 10: ''
Run Code Online (Sandbox Code Playgroud)

您可以使用各种技术更强大地接受用户的输入.